git - git 使用的差异版本是什么? diff2 还是 diff3?

标签 git diff git-diff

有谁知道 git 使用哪个 diff 版本?

This article例如,详细解释了假人的 diff 算法,但实际使用的算法是什么?

关于一般知识,这里有 diff2 的规范和 diff3 .

我知道你可以配置 git 来使用 diff2diff3

git config --global merge.conflictstyle diff3

最佳答案

你似乎混淆了 3 个不同的东西

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

Git 支持 4 种不同的差异算法。

您可以通过命令行指定为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 链接是对 myers 的描述算法,似乎与 2 向冲突标记 git 调用无关 diff2merge.conflictStyle .

同样,unix工具diff3与 git 调用的三向冲突标记无关 diff3 .

关于git - git 使用的差异版本是什么? diff2 还是 diff3?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34434750/

相关文章:

git - 如何支持一个 git repo 中的多个私有(private) npm 包?

git - 两个分支的力比较

git - git文件差异中这些红色条的含义是什么

git - 新的 git diff 压实启发式方法不起作用

git - 如何让 Git diff 忽略版本号更改?

ios - iOS 应用程序中使用的 API key 和 secret - 将它们存储在哪里?

git - 使用 GitHub 存储库和 SSH 登录的 Spring Boot 配置服务器

linux - 使用 svn diff 命令

c++ - 比较两个包含 double 的文件

linux - 使用 shell 或 diff 命令从两个 csv 文件中提取修改和添加的行