ein*_*ica 9 git diff diff3 git-config
我刚刚阅读了Git 2.35.0 的发行说明(尽管注释 2.35.1 已经可用)。
在这些发行说明中,我看到:
- 添加了“Zealous diff3”风格的合并冲突呈现。
我的问题:
tor*_*rek 10
新的“zealous diff3”风格是:
merge.conflictStyle = zdiff3
Run Code Online (Sandbox Code Playgroud)
你可以设置:
git config --global merge.conflictStyle zdiff3
Run Code Online (Sandbox Code Playgroud)
例如(假设您希望在每用户配置中使用此功能)。
默认样式是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.
Run Code Online (Sandbox Code Playgroud)
(此示例直接来自文档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.
Run Code Online (Sandbox Code Playgroud)
请注意,为了显示基本版本和两个分支提示版本之间的差异,该行:
or cleanly resolved because both sides changed the same way.
Run Code Online (Sandbox Code Playgroud)
以前位于该部分之外的<<<<<<< ... >>>>>>>内容(因为它已被彻底解决)现在位于该部分之内。
所做的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.
Run Code Online (Sandbox Code Playgroud)
这可以说是一个谎言,但却是一个有用的谎言。
请注意,如果您愿意,您可以采用任何现有的冲突文件并以新的合并样式重新创建冲突:
git checkout --conflict=zdiff3 conflicted.txt
Run Code Online (Sandbox Code Playgroud)
(或与相同,git restore但我还没有重新训练我的手指)。 请小心这一点,因为它会覆盖您在合并时所做的任何尝试。