`git push` 是否扩展为 `git push origin master`?
Does `git push` expand to `git push origin master`?
还是扩展到git push origin <current-branch-name>
?
参考资料
- http://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
git push [remote-name] [branch-name]
是的,如果你是 master,它会扩展到 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
。
TL;DR
默认情况下,git push
扩展为 git push origin <current-branch>
,因为旧版本为 Git 2.0
或 git push origin <all-matching-branches>
。
实际答案
关于 git push
的所有问题的答案都在 git push
的文档页面中:http://git-scm.com/docs/git-push
该页面的片段(我删除了无数选项,因为问题中没有提到它们):
git push ... [<repository>] [<refspec>]
When the command line does not specify where to push with the <repository>
argument, branch.*.remote
configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults to origin
.
When the command line does not specify what to push with <refspec>...
arguments or --all
, --mirror
, --tags
options, the command finds the default <refspec>
by consulting remote.*.push
configuration, and if it is not found, honors push.default
configuration to decide what to push (See git-config[1]
for the meaning of push.default
).
因为 Git 2.0
push.default
的默认值是 simple
这意味着 推送当前分支 一些检查和条件可以使 git
在某些情况下拒绝 push
。
在Git 2.0
之前,push.default
的默认值曾经是matching
,意思是压入两端同名的所有分支.此模式也需要满足一些条件才能成功。
有关 push.default
的更多详细信息,请参阅 git config
的文档页面或在您的终端上键入 git help config
。
还是扩展到git push origin <current-branch-name>
?
参考资料
- http://git-scm.com/book/en/v2/Git-Basics-Working-with-Remotes
git push [remote-name] [branch-name]
是的,如果你是 master,它会扩展到 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
。
TL;DR
默认情况下,git push
扩展为 git push origin <current-branch>
,因为旧版本为 Git 2.0
或 git push origin <all-matching-branches>
。
实际答案
关于 git push
的所有问题的答案都在 git push
的文档页面中:http://git-scm.com/docs/git-push
该页面的片段(我删除了无数选项,因为问题中没有提到它们):
git push ... [<repository>] [<refspec>]
When the command line does not specify where to push with the
<repository>
argument,branch.*.remote
configuration for the current branch is consulted to determine where to push. If the configuration is missing, it defaults toorigin
.When the command line does not specify what to push with
<refspec>...
arguments or--all
,--mirror
,--tags
options, the command finds the default<refspec>
by consultingremote.*.push
configuration, and if it is not found, honorspush.default
configuration to decide what to push (Seegit-config[1]
for the meaning ofpush.default
).
因为 Git 2.0
push.default
的默认值是 simple
这意味着 推送当前分支 一些检查和条件可以使 git
在某些情况下拒绝 push
。
在Git 2.0
之前,push.default
的默认值曾经是matching
,意思是压入两端同名的所有分支.此模式也需要满足一些条件才能成功。
有关 push.default
的更多详细信息,请参阅 git config
的文档页面或在您的终端上键入 git help config
。