Why cant Git merge file changes with a modified parent/master.

Posted by Andy on Stack Overflow See other posts from Stack Overflow or by Andy
Published on 2010-04-06T22:36:30Z Indexed on 2010/04/06 22:43 UTC
Read the original article Hit count: 207

Filed under:

I have a file with one line in it. I create a branch and add a second line to the same file. Save and commit to the branch. I switch back to the master. And add a different, second line to the file. Save and commit to the master. So there's now 3 unique lines in total.

If I now try and merge the branch back to the master, it suffers a merge conflict.

Why cant Git simple merge each line, one after the other?

My attempt at merge behaves something like this:

PS D:\dev\testing\test1> git merge newbranch
Auto-merging hello.txt
CONFLICT (content): Merge conflict in hello.txt
Automatic merge failed; fix conflicts and then commit the result.
PS D:\dev\testing\test1> git diff
diff --cc hello.txt
index 726eeaf,e48d31a..0000000
--- a/hello.txt
+++ b/hello.txt
@@@ -1,2 -1,2 +1,6 @@@
  This is the first line.
- New line added by master.
 -Added a line in newbranch.
++<<<<<<< HEAD
++New line added by master.
++=======
++Added a line in newbranch.
++>>>>>>> newbranch

Is there a way to make it slot lines in automatically, one after the other?

© Stack Overflow or respective owner

Related posts about git