为什么Git不能与修改后的父/主合并合并文件?

And*_*ndy 7 git

我有一个文件,其中包含一行.我创建了一个分支,并在同一个文件中添加了第二行.保存并提交到分支.我切换回主人.并在文件中添加不同的第二行.保存并提交给主人.所以现在共有3条独特的线路.

如果我现在尝试将分支合并回主服务器,则会遇到合并冲突.

为什么Gant不能简单地合并每一行,一个接一个?

我的合并尝试表现如下:

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
Run Code Online (Sandbox Code Playgroud)

有没有办法让它自动插槽,一个接一个?

Die*_*Epp 12

假设文件分支A看起来像:

First line
Branch A's second line
Run Code Online (Sandbox Code Playgroud)

分支B看起来像:

First line
Branch B's second line
Run Code Online (Sandbox Code Playgroud)

合并时,有两种不同的方法可以解决它.这是一种方式:

First line
Branch A's second line
Branch B's second line
Run Code Online (Sandbox Code Playgroud)

这是另一种方式:

First line
Branch B's second line
Branch A's second line
Run Code Online (Sandbox Code Playgroud)

Git不知道你喜欢哪两个选项,或者哪个都是可接受的合并.