How do I merge multiple branches into master?

git

Solution

Git's `merge` command supports multiple merging strategies. There are two strategies that can merge more than two branches at a time.

See also this question for 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 octopus strategy.

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 question for a use case example.

Problem

``` 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? something like: ``` git checkout master git merge b1 b2 b3 b4 ```

Original source

Related problems