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
To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch. This example merges the jeff/feature1 branch into the main branch.
Merging a branch multiple times into another works fine if there were changes to merge. Show activity on this post. Actually yes you totally can, when you merge again it will bring over any commits that don't exist on production.
In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With