I have a base branch base with a file called base.md(for the sake of understanding, i add the line number):
1: 2: 3: b Then I check out a new branch feat and edit the base.md as below:
1: 2: 3: b 4: 5: c I add a commit feat-1. Then I go back to branch base and edit base.md:
1: a 2: 3: b 4: After adding a commit base-1, I want to merge(using --conflict=diff3) feat into base but the merge conflicts occur:
01: a 02: 03: <<<<<<< ours 04: b 05: ||||||| base 06: 07: b 08: ======= 09: 10: b 11: 12: c 13: >>>>>>> theirs 14: You can see the character b located at line 3 in ours(Current Change) but at line 4 in both theirs(Incoming Change) and merge base. Actually, the b is located at line 3 in feat branch or merge base.
If I accept the current changes, it will be ok. But if the incoming changes, the file is changed to:
1: a 2: 3: 4: b 5: 6: c 7: Intuitively, I think there should be no conflicts and the changes(line c) appended to the end.
So why this happened? How git calculates the conflicts in this case?
merge.conflictStyletodiff3before you start your merge, or usegit checkout --conflict=diff3after merge stops with the merge conflict. You will see the three inputs that are causing the actual conflict, with the merge base version shown below the seven vertical bar markers|||||||.git checkout --conflict=diff3, gotbase.md: needs merge \n error: you need to resolve your current index first-mbut you can trygit checkout -m --conflict=diff3 base.md. You do have to specify one file; Git discards any progress you've made resolving the file and re-creates the conflict at this point.bchanged. Is this related to the line terminator?