I modified different lines in different branches, but those changes occur git merge
conflict.
I read the post, but I think the changes occur in totally different lines.
Here are my test codes.
Hello, my first conflict.
Second line.a # add a single character 'a' at line 2
Third line.
Hello, my first conflict.
Second line.
Third line.a # add a single character 'a' at line 3
And I executed the following code, it says git merge conflict.
$ git checkout branch-base
$ git merge branch-a
Here's my conflict file.
Hello, my first conflict.
<<<<<<< HEAD
Second line.a
Third line.
=======
Second line.
Third line.a
>>>>>>> branch-a
Why this conflict happens? I think I made changes in totally different lines (although those are adjacent.)
There has to be at least a single line of separation that remains the same so that they can be treated separately and not produce a conflict. Given that they are not separated by a line that stays the same on all 3 revisions (the two tips and the common ancestor) then they are treated as a single block. One branch modifies that block one way, the other in another way... so, conflict.