1

Say I have a file called README.md. On the first commit to master it looks like this:

1 line 1
2
3
4
5

After that commit I make a new branch called branch1. I make some changes and commit this to that branch:

1 line 1
2
3 line 3
4
5

I then switch back to master and make one final change to README.md:

1 line 1
2 line 2
3
4
5

I then attempt to merge branch1 into master but get a merge conflict:

line 1
+<<<<<<< destination:cc7a08f60b9dffc80ccdbdc4c0d74b1c89ef3a0d
line 2
+=======
+
+line 3
+>>>>>>> source:715105a18fc54b681cb451492bfe07bb49305a2e

Why can't the branch1 and master branch simply be merged into something that looks like this?:

1 line 1
2 line 2
3 line 3
4
5

What's the best way to achieve this?

phd
  • 82,685
  • 13
  • 120
  • 165
fromspace
  • 355
  • 3
  • 18
  • 2
    Because automerges that accept changes so close to each other without human intervention have an unacceptably bad track record. – jthill Jul 04 '17 at 23:18
  • This question elucidates how git processes conflicts. It may help you understand it. https://stackoverflow.com/questions/4920885/what-constitutes-a-merge-conflict-in-git – JSeven Jul 05 '17 at 15:39

0 Answers0