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

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

    This answer was given by Paul Pladijs. I just took his commands and made a git alias for convenience.

    Edit your .gitconfig and add the following:

    [alias]
        mergetheirs = "!git merge -s ours \"$1\" && git branch temp_THEIRS && git reset --hard \"$1\" && git reset --soft temp_THEIRS && git commit --amend && git branch -D temp_THEIRS"
    

    Then you can "git merge -s theirs A" by running:

    git checkout B (optional, just making sure we're on branch B)
    git mergetheirs A
    

提交回复
热议问题