提交结构
A
|\
| C (master)
|
B (origin/master)
A
1 apple
2 banana
3 coffee
B
1 apple
2 ball
3 coffee
4 doll
C
1 apple
2 banana
3 coffee
4 dirt
如果我将C
与B
合并以推送到远程服务器
生成的文件将是这样的
1 apple
2 ball
3 coffee
>>>>>> C
4 dirt
======
4 doll
<<<<<< B
但我希望显示所有这些变化
1 apple
>>>>> C
2 banana
=====
2 ball
<<<<< B
3 coffee
>>>>>> C
4 dirt
======
4 doll
<<<<<< B
我怎样才能做到这一点?
谢谢。
答案 0 :(得分:2)
标记<<<<<<
,=======
和>>>>>>>
用于表示git merge
中涉及的冲突(粗略地说,当给定的行已经发生冲突时并考虑在两个分支中同时修改。
关于你的问题,根据git merge的文档,似乎不可能完全(语法上)你的意思,因为只有在冲突的情况下(因此他们的名字)才会出现冲突标记。 / p>
但是,您可以使用git diff命令获取所需信息。以下是您在执行合并之前可以执行的操作:
git diff B..C # or what amounts to the same, git diff origin/master..master
diff --git a/file b/file
index e96d86d..258f327 100644
--- a/file
+++ b/file
@@ -1,4 +1,4 @@
1 apple
-2 ball
+2 banana
3 coffee
-4 doll
+4 dirt
最后,仅供参考,本文档解释了冲突时应遵循的典型工作流程:
https://git-scm.com/docs/git-merge#_how_to_resolve_conflicts
看到冲突后,你可以做两件事:
决定不合并。您需要的唯一清理是将索引文件重置为
HEAD
提交[...]并清理工作 [合并尝试]所做的树更改;git merge --abort
可用于 此解决冲突。 Git将标记工作树中的冲突。将文件编辑为形状,并将
git add
编辑为索引。使用git commit
或git merge --continue
来达成协议。 后一个命令检查是否有(中断) 在调用git commit之前进行合并。
希望这有帮助