0

I'm trying to git merge master from the command line.

There is a good number of conflicts. So far so good.

However, the conflict markers are placed incorrectly, which makes manual conflict resolution extra tedious.

I can't expose the code here, but it basically looks like this:

# some correctly identified conflicts followed by
# some code without conflicts:
dummy code 1
dummy code 2
<<<<<<<< HEAD 
some lines that don't come after dummy code 2 in HEAD # why??   
========
lines that come after dummy code 2 in master # this is OK 
dummy code 3
>>>>>>>> master
lines that come after dummy code 3 in master, but not after dummy code 2 in HEAD # i.e. there's a conflict here that git failed to identify

Whatever algo git merge uses to place those conflict markers, I would expect that removing everything between ======= and >>>>>> master should basically restore the HEAD version of the file. Which is not the case here.

I couldn't find much info about others encountering a similar issue (only this old question from 2016), just wondering what the cause of this might be?

Ôrel
  • 7,044
  • 3
  • 27
  • 46
the.real.gruycho
  • 608
  • 3
  • 17
  • You sure you are not rebasing? – eftshift0 Oct 28 '22 at 10:36
  • 2
    Just in case, to be able to _really_ help you , we would need to have that section of code (or equivalent with changed code) in 3 versions: current branch, the branch you are merging, the common ancestor (which can be known with `git merge-base HEAD the-other-branch`). Once we have that, we might be able to see what's going on. – eftshift0 Oct 28 '22 at 10:41
  • 3
    Set `merge.conflictStyle` to `diff3` to see the original conflict, rather than Git's attempt at merging plus whatever's left over. The original conflict *should* make more sense. – torek Oct 28 '22 at 10:49
  • another way to view the conflict is to call `git mergetool` and use an external tool to view and solve the conflict – LeGEC Oct 29 '22 at 08:18

0 Answers0