elmarco elmarco - 1 month ago 6x
Git Question

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

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 am aware of
git merge -s ours
. But what I want is something like
git merge -s theirs

Why doesn't it exist? How can I achieve the same result after the conflicting merge with existing
commands? (
git checkout
every unmerged file from B)

UPDATE: The "solution" of just discarding anything from branch A (the merge commit point to B version of the tree) is not what I am looking for.


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:


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.