Search code examples
gitgit-mergegit-merge-conflict

How can there be a merge conflict if I specified -Xours?


-Xours should mean that during merging one option always gets picked. So why do I still get merge conflicts?


Solution

  • Perhaps you know this already but the way you stated the premise isn't exactly right:

    -Xours should mean that during merging one option always gets picked.

    Note that the option -Xours (and also -Xtheirs) does a regular merge of both sides, and only when there is a conflict will it choose one side or the other. The automatic conflict resolution is for just the lines involved in the conflict, not the entire file.

    The key though is that the automatic conflict resolution only works when both files are modified. If at least one side is added or deleted instead of modified it will not perform automatic resolution. Presumably this is why it's happening for some of the conflicts in your case.