什么是diff版本git使用? diff2还是diff3?

时间:2015-12-23 11:32:22

标签: git diff git-diff

有没有人知道git使用的diff版本是什么?

This article例如详细解释了虚拟对象的差异算法,但是什么是使用的实际算法?

有关diff2&的规格的一般知识。 diff3

我知道您可以将git配置为使用diff2diff3

git config --global merge.conflictstyle diff3

2 个答案:

答案 0 :(得分:4)

你好像混淆了3个不同的东西

  1. GNU diffutils
  2. 提供的unix命令行工具diff3
  3. git提供的差异的输出格式(其中diff3是非默认选项)
  4. git用于生成diff
  5. 的算法

    Git支持4种不同的diff算法。

    您可以通过命令行指定git diff

      --minimal
           Spend extra time to make sure the smallest possible diff is produced.
    
       --patience
           Generate a diff using the "patience diff" algorithm.
    
       --histogram
           Generate a diff using the "histogram diff" algorithm.
    
       --diff-algorithm={patience|minimal|histogram|myers}
           Choose a diff algorithm. The variants are as follows:
       default, myers
           The basic greedy diff algorithm. Currently, this is the default.
    
       minimal
           Spend extra time to make sure the smallest possible diff is produced.
    
       patience
           Use "patience diff" algorithm when generating patches.
    
       histogram
           This algorithm extends the patience algorithm to "support low-occurrence common elements".
    

    或通过git配置。

      diff.algorithm
       Choose a diff algorithm. The variants are as follows:
    
       default, myers
           The basic greedy diff algorithm. Currently, this is the default.
    
       minimal
           Spend extra time to make sure the smallest possible diff is produced.
    
       patience
           Use "patience diff" algorithm when generating patches.
    
       histogram
           This algorithm extends the patience algorithm to "support low-occurrence common elements".
    

    原始问题中的diff2 pdf-link是对myers算法的描述,似乎与{diff2中的双向冲突标记merge.conflictStyle无关。 1}}。

    同样,unix工具diff3与3方冲突标记git调用diff3无关。

答案 1 :(得分:0)

我在config documentation中找到了答案:
git默认值是diff2

  

merge.conflictStyle

     

指定在合并时将冲突的帅哥写入工作树文件的样式。

     

默认为“merge”,显示<<<<<<<<<<冲突标记,
    由一方做出的改变,a =======标记,
    另一方做出的改变,
    然后是>>>>>>>>标记。另一种风格,

     

“diff3”,添加|||||||标记和=======标记之前的原始文本。