git 如何将多个分支合并到 master 中?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16208144/
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
How do I merge multiple branches into master?
提问by nfpyfzyf
C---D =>b1
/
/ E---F =>b2
| /
A--B =======> master
| \
\ G---H =>b3
\
I---J =>b4
I want to merge b1
,b2
,b3
,b4
into master
, is it possible merge at once?
我想将b1
, b2
, b3
,合并b4
到master
,是否可以一次合并?
something like:
就像是:
git checkout master
git merge b1 b2 b3 b4
回答by Alexei Sholik
Git's merge
command supports multiple merging strategies. There are two strategies that can merge more than two branches at a time.
Git 的merge
命令支持多种合并策略。有两种策略可以一次合并两个以上的分支。
See also this questionfor a less formal description of each one.
octopus
章鱼
This resolves cases with more than two heads, but refuses to do a complex merge that needs manual resolution. It is primarily meant to be used for bundling topic branch heads together. This is the default merge strategy when pulling or merging more than one branch.
这解决了具有两个以上头的情况,但拒绝进行需要手动解决的复杂合并。它主要用于将主题分支头捆绑在一起。这是拉取或合并多个分支时的默认合并策略。
The last statement implies that if you do git merge branch1 branch2 ...
, it'll use the octopusstrategy.
最后一条语句暗示,如果您这样做git merge branch1 branch2 ...
,它将使用章鱼策略。
ours
我们的
This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches.
这可以解析任意数量的头,但合并的结果树始终是当前分支头的树,有效地忽略了所有其他分支的所有更改。它旨在用于取代旧的侧枝发展历史。
See this questionfor a use case example.
有关用例示例,请参阅此问题。
回答by jbr
Git has a merging strategy called octupus which can merge multiple branches, as long as there are no complex conflicts. The command to do this is exactly as you suggested git merge b1 b2
.
Git有一个合并策略叫做octupus,可以合并多个分支,只要没有复杂的冲突。执行此操作的命令与您建议的完全相同git merge b1 b2
。