Is there a “theirs” version of “git merge -s ours”?

前端 未结 18 1764
傲寒
傲寒 2020-11-22 06:42

When merging topic branch \"B\" into \"A\" using git merge, I get some conflicts. I know all the conflicts can be solved using the version in \"B\".

I a

18条回答
  •  一整个雨季
    2020-11-22 07:07

    The equivalent(which keep parent order) to 'git merge -s theirs branchB'

    Before merge:

    !!! Make sure you are in clean state !!!

    Do the merge:

    git commit-tree -m "take theirs" -p HEAD -p branchB 'branchB^{tree}'
    git reset --hard 36daf519952 # is the output of the prev command
    

    What we did ? We created a new commit which two parents ours and theirs and the contnet of the commit is branchB - theirs

    After merge:

    More precisely:

    git commit-tree -m "take theirs" -p HEAD -p 'SOURCE^{commit}' 'SOURCE^{tree}'
    

提交回复
热议问题