我有一个文件,里面只有一行。
我创建一个分支并向同一文件添加第二行。保存并提交到分支。
我切换回主人。并向文件中添加不同的第二行。保存并提交给master。
现在总共有 3 条独特的线路。
如果我现在尝试将分支合并回主分支,则会遇到合并冲突。
为什么 Git 不能简单地逐行合并呢?
我尝试合并的行为如下:
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
有没有办法让它自动一条一条地插入线?
假设文件分支 A 如下所示:
First line
Branch A's second line
分支 B 看起来像:
First line
Branch B's second line
合并时,有两种不同的方法来解决它。这是一种方法:
First line
Branch A's second line
Branch B's second line
这是另一种方法:
First line
Branch B's second line
Branch A's second line
Git 不知道您更喜欢这两个选项中的哪一个,或者是否可以接受合并。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)