git push - doc-cloud/git GitHub Wiki

默认推送所有分支:

$ git push

只推送dev分支到远程origin:

$ git push -u origin dev

error occured, when I use git push, it is not work. and it work well after I set the default push way, and in a simpler output way, it may be version mistake.

[root@Linkerist-Lenovo-G500:22:24:08: /vay/ds #] git push
warning: push.default is unset; its implicit value is changing in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the current behavior after the default changes, use:

  git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

  git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

In Git 2.0, Git will default to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

^C
[root@Linkerist-Lenovo-G500:22:25:19: /vay/ds #] 
[root@Linkerist-Lenovo-G500:22:25:20: /vay/ds #] 
[root@Linkerist-Lenovo-G500:22:25:20: /vay/ds #] git config --global push.default simple
[root@Linkerist-Lenovo-G500:22:26:54: /vay/ds #] git push
Counting objects: 38, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (23/23), done.
Writing objects: 100% (24/24), 3.34 KiB | 0 bytes/s, done.
Total 24 (delta 17), reused 0 (delta 0)
To [email protected]:Linkerist/ds.git
   f44e5f2..3d06eca  master -> master
[root@Linkerist-Lenovo-G500:22:27:02: /vay/ds #]

error

[root@linkerist-desktop:08:09:42: /vay/proj/mcc #] git push
To [email protected]:Linkerist/mcc.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:Linkerist/mcc.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
[root@linkerist-desktop:08:09:48: /vay/proj/mcc #]

netlinkerr

it is the network link error of my router, use ssh way, instead of https

[root@Linkerist-Lenovo-G500:22:49:25: /vay/command #] git push
ssh: Could not resolve hostname github.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[root@Linkerist-Lenovo-G500:22:49:28: /vay/command #]

[root@Linkerist-Lenovo-G500:22:49:25: /vay/command #] git push
ssh: Could not resolve hostname github.com: Name or service not known
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
[root@Linkerist-Lenovo-G500:22:49:28: /vay/command #]

ssh-instead-https

[root@linkerist-desktop:14:47:48: ~/log-patch #] git remote -v
origin	https://github.com/Linkerist/log-patch.git (fetch)
origin	https://github.com/Linkerist/log-patch.git (push)
[root@linkerist-desktop:14:47:53: ~/log-patch #] 
[root@linkerist-desktop:14:48:06: ~/log-patch #] git remote rm origin
[root@linkerist-desktop:14:48:21: ~/log-patch #] git remote add origin [email protected]:Linkerist-bio/log-patch.git
[root@linkerist-desktop:14:49:40: ~/log-patch #] git add test.txt 
[root@linkerist-desktop:14:49:43: ~/log-patch #] git commit -m "that is okay"
[master d771b8c] that is okay
 1 file changed, 3 insertions(+)
[root@linkerist-desktop:14:49:53: ~/log-patch #] git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

[root@linkerist-desktop:14:49:56: ~/log-patch #] git push --set-upstream origin master
Counting objects: 8, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 554 bytes | 0 bytes/s, done.
Total 6 (delta 3), reused 0 (delta 0)
To [email protected]:Linkerist-bio/log-patch.git
   9d5533f..d771b8c  master -> master
Branch master set up to track remote branch master from origin.
[root@linkerist-desktop:14:50:16: ~/log-patch #] vi test.txt