gpt4 book ai didi

git - diff和diff = astextplain有什么区别?

转载 作者:行者123 更新时间:2023-12-03 07:28:02 24 4
gpt4 key购买 nike

有人能帮我吗。我正在使用Git(GitHub)并试图决定在gitattributes中将*.sql文件设置为什么。我见过人们用

*.sql diff=astextplain
*.sql diff
*.sql text=auto

有人建议我将此设置为第二个选项,但是我只是想知道它与其他两个选项有什么区别。

最佳答案

TL; DR

  • diff=astextplain(仅msysGit):在生成差异之前,将这些文件(在扩展名为*.doc*.pdf*.rtf等的情况下)转换为文本格式。
  • diff:将那些文件视为纯文本以生成它们的差异。
  • text=auto:自动将Git视为文本文件的文件中的EOL字符(转换为LF)。

  • 更多细节
    diff=astextplain
    字符串值 astextplain不属于Git核心:实际上,正在运行
    git grep "astextplain"

    Git project repository中不返回任何内容。据我所知,这是 shell script附带的 msysGit,可让您转换诸如
  • Word文档
  • PDF,
  • RTF

  • 生成差异之前将其转换为文本格式。
    diff
    根据 gitattributes man page:

    The attribute diff affects how Git generates diffs for particular files. [...]

    A path to which the diff attribute is set is treated as text, even when they contain byte values that normally never appear in text files, such as NUL.


    text=auto
    根据 gitattributes man page:

    When text is set to "auto", the path is marked for automatic end-of-line normalization. If Git decides that the content is text, its line endings are normalized to LF on checkin.

    关于git - diff和diff = astextplain有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28146244/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com