git使用的差异版本是什么? diff2或diff3? [英] What is the diff version git uses? diff2 or diff3?

查看:146
本文介绍了git使用的差异版本是什么? diff2或diff3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Does anyone know which diff version is used by git?

例如,本文详细说明了虚拟变量的diff算法,但是实际使用的算法是什么?

This article for example explains in detail the diff algorithm for dummies but what is the actual algorithm which is used?

对于常识,这里是 diff2 diff3

For general knowledge here are the specs for diff2 and diff3.

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

I know you can configure git to use diff2 or diff3

git config --global merge.conflictstyle diff3


推荐答案

您似乎对3种不同的东西感到困惑

You seem to be confusing 3 different things


  1. Unix命令行工具 diff3 GNU d提供iffutils

  2. git提供的diff的输出格式(其中 diff3 是非默认选项)

  3. git用来生成差异的算法

  1. The unix command line tool diff3 provided by GNU diffutils
  2. The output format of the diff that git provides (in which diff3 is a non-default option)
  3. The algorithm that git uses to generate the diff

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

Git supports 4 different diff algorithms.

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

You can specify via the command line to 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 算法的描述,似乎与git调用 diff2 的两向冲突标记无关在 merge.conflictStyle 中。

The diff2 pdf-link in your original question is a description of the myers algorithm, and seems to be unrelated to the 2-way conflict markers git calls diff2 in merge.conflictStyle.

类似地,unix工具 diff3 与git调用 diff3 的三向冲突标记无关。

Similarly, the unix tool diff3 is unrelated to the 3-way conflict markers git calls diff3.

这篇关于git使用的差异版本是什么? diff2或diff3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆