提交结构
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
我怎样才能做到这一点?
谢谢。
标记<<<<<<
,=======
和>>>>>>>
用于表示git merge
中涉及的冲突(粗略地说,当在所考虑的两个分支中同时修改给定线时发生冲突)。
关于你的问题,根据git merge的文档,似乎不可能完全(语法上)你的意思,因为冲突标记只出现冲突(因此他们的名字)。
但是,您可以使用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
commit [...]并清除[合并尝试]所做的工作树更改;git merge --abort
可以用于此。- 解决冲突。 Git将标记工作树中的冲突。将文件编辑为形状,并将
git add
编辑为索引。使用git commit
或git merge --continue
来达成交易。后一个命令在调用git commit之前检查是否存在正在进行的(中断的)合并。
希望这会有所帮助