“git push”是否推送来自其他分支的所有提交?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19088396/
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
Does "git push" push all commits from other branches?
提问by Bart?omiej Zalewski
If I have many unpushed commits spread among many branches in my local repo, what happens if I type git push? Will all of those commits be pushed or only those which belong to the current branch?
如果我有许多未推送的提交分布在我本地存储库的许多分支中,如果我输入会发生什么git push?会推送所有这些提交还是只推送属于当前分支的提交?
采纳答案by VonC
It also depends on your push policies (git config push.default).
它还取决于您的推送策略 ( git config push.default)。
As I explain in "git - push current vs. push upstream (tracking)", only the "matching" policy pushes more than the current branch.
正如我在“ git - push current vs. push upstream(跟踪)”中解释的那样,只有“匹配”策略比当前分支推送更多。
push all branches having the same name on both ends.
This makes the repository you are pushing to remember the set of branches that will be pushed out (e.g. if you always pushmaintandmasterthere and no other branches, the repository you push to will have these two branches, and your localmaintandmasterwill be pushed there).
在两端推送所有具有相同名称的分支。
这使得库你是推记住设置将要推出的分支(例如,如果你总是推maint和master有其他分支机构,你推到会有这两个分支的库,和当地的maint和master将在那里推)。
With that policy, only a simple git pushis enough to push all (matching) branches.
Without that policy, a git push --allis necessary to forceall branches to be pushed.
使用该策略,只需一个简单的git push就足以推送所有(匹配)分支。
如果没有该策略,git push --all则需要强制推送所有分支。
回答by Shimon Rachlenko
No, git pushonly pushes commits from current local branch to remote branch that you specified in command.
不,git push只将提交从当前本地分支推送到您在命令中指定的远程分支。
You cantell git to push all branches by setting the --allargument
您可以通过设置--all参数告诉 git 推送所有分支
See the command description
查看命令说明

