In short, why does a file foo.txt
having content
a
b
failed to merge with the branch with foo.txt
having content:
a
c
?
The longer version is: to experiment with Git and merging, I did the following:
mkdir
a new directory andcd
into it andgit init
- create a file
foo.txt
and add the linea
(first time just like that, and second time with 2 empty lines aftera
) - commit it, and now
git checkout -b feature
andgit checkout -b sprint
(so as far as I know, it makes no difference to do it in a row instead of first switching back tomaster
and createsprint
, because branches are created based on commitID, and either case, they are exactly the same. - Now
git co feature
and make the file look likea
and then empty line and thenc
on the third line - Now commit it, and do
git checkout sprint
and make the file look likea
and then next lineb
on its own. - Now commit it, and now do a
git merge feature
and supposedly, the merge could have succeeded, with the content
a
b
c
but why did it fail? Instead of guessing "maybe the lines are too close", can a more definitive answer from docs or reference be given?
I also tried adding an empty line between a
and b
, and between b
and c
so they are more spaced out, but without the initial empty lines in the first version of foo.txt
, and the result was the same: merge conflict.