我刚刚阅读了Git 2.35.0 的发行说明(尽管说明 2.35.1 已经可用)。
在那些发行说明中,我看到:
- 添加了“Zealous diff3”风格的合并冲突表示。
我的问题:
- 如何使 git diff / difftool 默认为“热心”差异演示?
- 在默认的差异演示模式下使用它有什么优缺点?
我刚刚阅读了Git 2.35.0 的发行说明(尽管说明 2.35.1 已经可用)。
在那些发行说明中,我看到:
- 添加了“Zealous diff3”风格的合并冲突表示。
我的问题:
新的“热心 diff3”风格是:
merge.conflictStyle = zdiff3
你设置的:
git config --global merge.conflictStyle zdiff3
例如(假设您希望在每用户配置中使用它)。
默认样式是merge
:
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
(此示例直接来自文档git merge
)。该diff3
样式在中间添加了合并基础版本,带有竖线:
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
<<<<<<< yours:sample.txt
or cleanly resolved because both sides changed the same way.
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
or cleanly resolved because both sides changed the same way.
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
请注意,为了显示基本版本和两个分支提示版本之间的差异,以下行:
or cleanly resolved because both sides changed the same way.
曾经在该部分之外<<<<<<< ... >>>>>>>
(因为它已被干净地解决)现在在该部分内。
什么zdiff3
是采用相同的“或完全解决”的路径merge
:
Here are lines that are either unchanged from the common
ancestor, or cleanly resolved because only one side changed,
or cleanly resolved because both sides changed the same way.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
||||||| base:sample.txt
or cleanly resolved because both sides changed identically.
Conflict resolution is hard.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.
这是一个谎言,在某种程度上,但它是一个有用的谎言。
请注意,如果您愿意,您可以获取任何现有的冲突文件并以新的合并样式重新创建冲突:
git checkout --conflict=zdiff3 conflicted.txt
(或相同,git restore
但我还没有重新训练我的手指)。 请注意这一点,因为它会覆盖您在合并时所做的任何尝试。