So I have this simple file with 3 lines:
some
random
words
First Merge Test
I created two different branches with the file in the original state at the top of this post from master. I create branch merge1
that changes the first line from some
to will
. I create branch merge2
that changes line 3 from words
to work
. I merge merge1
first and the merge2
second into master and everything work fine as expected.
Second Merge Test
I created two different branches with the file in the original state at the top of this post from master. I create branch merge1
that changes the first line from some
to doesnt
. I create branch merge2
that changes line 2 from random
to work
. I merge merge1
first and that works however when I try to merge merge2
I get a conflict error that I was not expecting.
When I open the file, this is what I see:
<<<<<<< HEAD
doesnt
random
=======
some
work
>>>>>>> merge2
words
What I don't understand is why the merge2 show the first line as some
since merge2 did not change that line. This is ironically something the SVN handles fine.
Am I missing something here? Why can I have 2 different branches that are created from the same commit modify different lines of the small file just fine but not be able to change consecutive lines?
git config --global merge.conflictstyle diff3
. It may make more sense. Keep in mind, also, that merges work by applying patches (think Unified Diff format), which means that in such a small test, there may not be enough unaltered context lines to determine what needs to change.