【发布时间】:2015-11-23 13:54:39
【问题描述】:
根据这篇文章: What is the purpose of `text=auto` in `.gitattributes` file? 如果 .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
根据下面的 cmets/answers,似乎有这个导致的警告:
* 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。
警告确实 NOT 解决了在 check-in 行将具有 LF 结尾的问题,这就是文档在此处所说的:
https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html
设置为字符串值“auto” 当文本设置为“自动”时,路径被标记为自动行尾标准化。如果 Git 确定内容是文本,则在签入时将其行结尾规范化为 LF。
【问题讨论】:
-
相关的是,但不是我在这里要求的。这里是关于特定警告消息的含义,并将其与公共文档中的描述进行比较。
-
警告不是由
text=auto引起的,而是text=auto与您之前设置的其他选项有效交互。另一个问题涵盖了其他选项。
标签: git gitattributes