Git:使用多个单引用合并模拟章鱼合并
Git: simulate octopus merge using multiple single ref merges
我知道我可以使用 git merge ref1 ref2
触发章鱼合并,但是否也可以使用多个命令获得相同的结果,例如
git merge --no-commit ref1
git merge --no-commit --magic-option ref2
git commit
或
之后
git merge ref1
git merge ref2
将最后 2 次合并提交变成 1 次章鱼合并提交?
您可以进行单独的合并,然后使用 git commit-tree
创建一个新的合并修订...所以...像这样:
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
我知道我可以使用 git merge ref1 ref2
触发章鱼合并,但是否也可以使用多个命令获得相同的结果,例如
git merge --no-commit ref1
git merge --no-commit --magic-option ref2
git commit
或
之后git merge ref1
git merge ref2
将最后 2 次合并提交变成 1 次章鱼合并提交?
您可以进行单独的合并,然后使用 git commit-tree
创建一个新的合并修订...所以...像这样:
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