When merging one git branch into another, a common source of merge conflicts is on one of my XML files, where new (but different) XML has been added at the same insertion point of the file on both branches. In my case, I want git to automatically include the newly inserted XML from both branches in the merged result, and I don't care which branch's changes gets inserted above the other.
Is it possible to configure git to do this?
Edit: I have found that I can put the line:
*.xml merge=union
Into the .gitattributes file - but this isn't working quite the way I would want.
Say on my working branch, this XML has been added:
<itemlist id="1">
<item id="1"></item>
</itemlist>
And then on the branch that I intend to merge into mine, this has been added - at exactly the same location:
<itemlist id="2">
<item id="2"></item>
</itemlist>
Then, git notices that both sets of changes end in the same text (i.e. the line with the end tag on). It seems to think that because both sides have added the same text, it shouldn't duplicate that text in the merge, so it only ends up inserting the following during the merge:
<itemlist id="2">
<item id="2"></item>
Which of course results in invalid XML.
Is there further configuration I can do to switch off this "only-merge-changes-that-are-not-also-changes-in-the-working-branch" option?