git Git将其他分支合并到另一个分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20603846/
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
Git merge other branch into another branch?
提问by Sato
Is it possible to merge other branch into another branch?
是否可以将其他分支合并到另一个分支?
For example, I'm in branch1
and want to pull remote/develop
into develop
branch and then merge develop into current branch1
.
例如,我在branch1
并想remote/develop
进入develop
分支,然后将 develop 合并到 current branch1
。
What am I doing is checkout develop
(maybe stash
first), pull
, checkout branch1
and then merge develop
.
我在做什么是checkout develop
(也许stash
第一), pull
,checkout branch1
然后merge develop
。
Is it possible to do all these with switch to develop
branch ?
是否可以通过 switch to develop
branch来完成所有这些?
回答by amahfouz
What you are doing is the right thing.
你正在做的是正确的事情。
git checkout develop
git pull
git checkout branch1
git merge develop
I don't if you are asking for a shorthand for these commands or what, but this is the sequence I always use.
如果您要求使用这些命令的简写或什么,我不会,但这是我一直使用的顺序。
回答by Nick
A slightly quicker option would be to (while on branch1
):
稍微快一点的选择是(在 上branch1
):
git fetch
git merge remote/develop
This will get your remote/develop
merged into branch1
, however it should be noted that your local develop branch won't be updated.
这将使您remote/develop
合并到branch1
,但是应该注意的是,您的本地开发分支不会更新。