基于这篇文章: `.gitattributes` 文件中`text=auto` 的目的是什么?如果 .gitattributes 文件中有以下内容,则 行尾将转换为文本文件的LF :
* text=auto
我刚刚在本地存储库上对此进行了测试:
$ git add -A
warning: LF will be replaced by CRLF in [bla]/.gitattributes.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in [bla]/.gitignore.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in [bla]/README.md.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in [bla].csproj.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in
但是那里说它将转换为CRLF。在上面的帖子中,它说它将转换为LF,而在此测试中并非如此。
所以看起来:
* text=auto
将转换为基于操作系统的行尾类型(Windows 为 CRLF,Linux 为 LF)。但这不是这里所描述的:
https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
根据以下评论/答案,似乎有此警告:
* text=auto
在 .gitattributes 文件中:
warning: LF will be replaced by CRLF in [bla]/README.md.
The file will have its original line endings in your working directory.
实际上意味着当您进行检出时(下次您将文件从存储库检出到您的工作目录)当前以LF结尾的文本文件将被转换为具有CRLF。
该警告没有解决签入行将具有LF结尾的问题,这就是文档在此处所说的内容:
https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
设置为字符串值“auto” 当文本设置为“auto”时,路径被标记为自动行尾标准化。如果 Git 确定内容是文本,则在签入时将其行结尾规范化为 LF。