Thomas S.
Thomas S.

Reputation: 6335

Git: simulate octopus merge using multiple single ref merges

I know I can trigger an octopus merge using git merge ref1 ref2, but is it also possible to get the same result using multiple commands, e.g.

git merge --no-commit ref1
git merge --no-commit --magic-option ref2
git commit

or after

git merge ref1
git merge ref2

turn the last 2 merge commits into 1 octopus merge commit?

Upvotes: 0

Views: 84

Answers (1)

eftshift0
eftshift0

Reputation: 30156

You could do separate merges, and then create a new merge revision with git commit-tree... so.. something like this:

git checkout --detach brancha # so that the branch doesn't move
git merge branchb -m "Whatever"
git merge branchc -m "Whatever again"
# now we do our magic
git checkout $( git commit-tree -m "Here's the octopus merge" -p brancha -p branchb -p branchc HEAD^{tree} )
# last command creates a new revision with brancha branchb and branchc as parents, will hold the tree of the last merge.. and we check it out
# if you like it, you can move any of the branches and then check it out
git branch -f brancha
git checkout brancha

Upvotes: 3

Related Questions