或者它是否扩展到git push origin <current-branch-name>
?
引用
- http://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
-
git push [remote-name] [branch-name]
-
TL;DR
默认情况下,git push
会扩展到自 Git 2.0
年以来的git push origin <current-branch>
或旧版本git push origin <all-matching-branches>
。
实际答案
有关git push
的所有问题的答案都在 git push
的文档页面中:http://git-scm.com/docs/git-push
该页面的一个片段(我删除了无数选项,因为它们在问题中没有提到):
git push ... [<repository>] [<refspec>]
当命令行未指定使用
<repository>
参数推送的位置时,将参考当前分支branch.*.remote
配置以确定推送位置。如果缺少配置,则默认为origin
。当命令行没有指定使用
<refspec>...
参数或--all
、--mirror
、--tags
选项推送什么时,该命令通过查阅remote.*.push
配置来查找默认<refspec>
,如果未找到,则遵循push.default
配置来决定推送什么(有关push.default
的含义,请参阅git-config[1]
)。
由于Git 2.0
push.default
的默认值是simple
这意味着使用一些检查和条件推送当前分支,这些检查和条件可以使git
在某些情况下拒绝push
。
在Git 2.0
之前,push.default
的默认值曾经是matching
这意味着在两端推送所有具有相同名称的分支。此模式还需要满足一些条件才能成功。
有关push.default
的更多详细信息,请参阅git config
的文档页面或在终端上键入git help config
。
是的,如果你是主版,它会扩展到git push origin master
。
如果您在分支上mybranch
它会扩展到 git push origin mybranch
。
如果您从未推送过mybranch
,则会出现以下消息:
fatal: The current branch mybranch has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin mybranch
然后你必须为第一个push
执行一次git push --set-upstream origin mybranch
,从那时起你可以做一个git push
,它将扩展到git push origin mybranch
。