git push 的格式详见 这里。
之前 git push 的默认操作是matching:
all your branches were sent to the remote as long as there already are branches of the same name over there.
在新出的 Git-1.8.0 中提到在下个版本中(注意不是1.8.0)会将 git push 的默认操作设为simple:
We will use the "simple" semantics that pushes the current branch to the branch with the same name, only when the current branch is set to integrate with that remote branch.
强烈建议用 git push 时输入完整的命令,而不是简单的 git push,因为你不知道默认的 git push 到底会做什么意想不到的操作。
$ git push <repository> <refspec> …
$ git push origin test:master
$ git push origin test:test
$ git push origin :test
附:
强推,即利用强制覆盖的方式用本地的分支替代远程库中的分支,慎用:
$ git push -f origin test:test
设置 git push 的默认操作:
$ git config --global push.default upstream
还有,有时候 git push 的时候出现这种错误:
$ git push fatal: The current branch hotfix has no upstream branch.这是没有指定当前分支跟踪的远程分支,所以git不知道要推送到哪,可以用git push --set-upstream设定:
$ git push --set-upstream origin hotfix ... Branch hotfix set up to track remote branch hotfix from origin.