【问题标题】:git - force lf line endings does not catch binariesgit - 强制 lf 行结尾不捕获二进制文件
【发布时间】:2018-11-26 11:57:28
【问题描述】:

根据Force LF line endings using .gitattributes without losing automatic text/binary inference?,当我将 .gitattributes 设置为仅包含时

* text=auto
* text eol=lf

然后所有文本文件都应该转换为 LF 行结尾,并且二进制文件应该保持不变——这就是我想要的。但不知何故,这里没有正确检测到二进制文件。在 Windows 下查看 git bash 控制台的输出:

$ git add .
warning: CRLF will be replaced by LF in clip2txt.exe.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in raw.png.
The file will have its original line endings in your working directory
warning: CRLF will be replaced by LF in test.
The file will have its original line endings in your working directory

我已经预料到,raw.png 和 clip2txt.exe 被忽略,因为它们是二进制文件。文件测试将被正确转换,很好。

我在这里错过了什么吗? 谢谢你, 亚历克斯

【问题讨论】:

  • AFAIU 接受的答案第二行过多。你只需要第一个。
  • 如果我只使用 * text=auto,那么由于我在 windows 上,它会尝试将所有文​​件转换为 crlf,这不是我想要的
  • 第二行是 all files 文本,这肯定不是你想要的。在一行中尝试* text=auto eol=lf
  • 嗯,很有趣。这是黑暗中的短暂,我很高兴它有所帮助。

标签: windows git line-endings


【解决方案1】:

如果有人对此进行调查,我将其标记为已回答:

解决方案是将 .gitattributes 设置为

* text=auto eol=lf

感谢@phd

【讨论】:

    猜你喜欢
    • 2014-11-22
    • 2015-04-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-29
    • 2011-01-31
    相关资源
    最近更新 更多