git push origin 和 git push origin master 有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12462481/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the difference between git push origin and git push origin master
提问by Hilbert-
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
?
将本地 git 存储库的 master 分支推送到名为 origin withgit push origin master
或 with的远程存储库的 master 分支有什么区别git push origin
吗?
采纳答案by ouah
The default action of git push
and git push origin
has changed since git
version 1.7.11
:
的默认操作git push
和git push origin
自改变git
版本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.
之前
1.7.11
,git push
默认情况下推送所有远程存在的同名分支。由于
1.7.11
,git push
默认情况下将当前分支推送到具有相同名称的远程分支。
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
.
在 version 之前和之后1.7.11
,可以使用push.default
配置选项配置默认行为。此配置选项已在git
版本中引入1.6.3
。
回答by bluesman
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
更新 - 自编写此答案以来,Git 的行为已发生变化。 git push origin
在 Git >=2.0 默认情况下,将当前分支推送到相同名称的匹配分支,但可以通过覆盖此行为git config