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?