What is the difference between git push origin and git push origin master

跟風遠走 提交于 2019-11-26 10:57:24

问题


Is there any difference in pushing the master branch of a local git repository to the master branch of a remote repository called origin with git push origin master or with git push origin?


回答1:


The default action of git push and git push origin has changed since git version 1.7.11:

  • Before 1.7.11, git push by default pushes all branches that also exist remotely with the same name.

  • Since 1.7.11, git push by default pushes the current branch to a remote branch with the same name.

Before and after version 1.7.11, the default behavior can be configured with the push.default configuration option. This configuration option has been introduced in git version 1.6.3.




回答2:


git push origin master

This only pushes your master branch to origin

git push origin

Pushes all your branches to origin

UPDATE - The behavior of Git has changed since this answer was written. git push origin on Git >=2.0 by default pushes the current branch to a matching branch of the same name, but this behavior can be overridden via git config



来源:https://stackoverflow.com/questions/12462481/what-is-the-difference-between-git-push-origin-and-git-push-origin-master

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!