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

前端 未结 18 1769
傲寒
傲寒 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:08

    Add the -X option to theirs. For example:

    git checkout branchA
    git merge -X theirs branchB
    

    Everything will merge in the desired way.

    The only thing I've seen cause problems is if files were deleted from branchB. They show up as conflicts if something other than git did the removal.

    The fix is easy. Just run git rm with the name of any files that were deleted:

    git rm {DELETED-FILE-NAME}
    

    After that, the -X theirs should work as expected.

    Of course, doing the actual removal with the git rm command will prevent the conflict from happening in the first place.


    Note: A longer form option also exists.

    To use it, replace:

    -X theirs
    

    with:

    --strategy-option=theirs
    

提交回复
热议问题