问题
I just downloaded the most recent version of Git to my Windows platform. I have a file with the following content committed:
Line 1 Line 2 Line 3 Line 4
I then create a branch with: git branch development
I continue on the master branch and modify the first line so I now have:
Line 1master Line 2 Line 3 Line 4
I stage and commit the change on the master branch. I switch to the development branch and modify the second line so I now have:
Line 1 Line 2development Line 3 Line 4
I stage and commit the change on the development branch. I now switch back to the master branch. I attempt to merge the development branch with:
git merge development
I get the following conflict:
<<<<<<<< HEAD Line 1master Line 2 ======= Line 1 Line 2development >>>>>>> development Line 3 Line 4
But why? After the branch was created, a change was made each on the master and development branches. But they were to different lines in the file. So why a conflict?
回答1:
You get the conflict because you made the development branch before commiting the changes on master, so master has different content (line1master) at the moment you try to merge the development branch.
this image illustrates better the case;
来源:https://stackoverflow.com/questions/36385887/why-do-i-get-a-merge-conflict