[英]Git push branch from different checked out branch
Can you 'git push origin branch1' while you have branch2 checked out? 您可以在签出branch2的同时“ git push origin branch1”吗?
git checkout branch1
git commit -am 'changes 1'
git checkout branch2
git commit -am 'changes 2'
git push origin branch1
Will that only push branch1 to the remote repo or will branch2 changes be pushed? 会只将branch1推送到远程仓库,还是会推送branch2的更改?
git push <repository> <refspec>
Will only push the specified refs to the remote specified. 仅将指定的引用推送到指定的远程。 In the case where
<refspec>
is a branch name, only that remote branch will be updated. 如果
<refspec>
是分支名称,则仅更新该远程分支。
If <refspec>
is not specified, the behavior is controlled by the push.default
configuration variable. 如果未指定
<refspec>
,则该行为由push.default
配置变量控制。
More information is available on the git-push(1) and git-config(1) man pages. 有关更多信息,请参见git-push(1)和git-config(1)手册页。
It depends on what push.default is configured to. 这取决于push.default配置为什么。 If you
git config push.default = matching
and you have remote branches branch1 and branch2, yes both branch1 and branch2 will be push. 如果您
git config push.default = matching
并且具有远程分支branch1和branch2,则yes,则branch1和branch2都会被推送。
Final answer is to use -n
to see what would happen without actually pushing: 最终的答案是使用
-n
来查看如果不实际推动就会发生什么:
git push -n
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.