【发布时间】:2013-01-24 21:54:51
【问题描述】:
我在 Windows 下使用 Git 来签入一些文件。我收到了类似的警告
foobar 中的 LF 将被替换为 CRLF
这个警告是什么意思?我可以做些什么来阻止这个警告吗?
【问题讨论】:
标签: git
我在 Windows 下使用 Git 来签入一些文件。我收到了类似的警告
foobar 中的 LF 将被替换为 CRLF
这个警告是什么意思?我可以做些什么来阻止这个警告吗?
【问题讨论】:
标签: git
这与core.autocrlf 选项有关。手册是这样说的:
core.autocrlf
Setting this variable to "true" is almost the same as setting the
text attribute to "auto" on all files except that text files are
not guaranteed to be normalized: files that contain CRLF in the
repository will not be touched. Use this setting if you want to
have CRLF line endings in your working directory even though the
repository does not have normalized line endings. This variable can
be set to input, in which case no output conversion is performed.
Git 警告您他为您更改了行终止符。
我建议为项目设置全局策略(如“始终使用 unix 行结束”,反之亦然)并禁用此选项。有时事情会变得一团糟,提交差异会包含大量额外的空白更改。
【讨论】:
msysgit 默认系统配置为core.autocrlf = true,表示开启CRLF转换。
【讨论】:
这可能意味着您尝试添加一个以 LF 行结尾的文件,并且您打开了 core.autocrlf。将文件转换为 CR/LF 行结尾,或关闭core.autocrlf。
【讨论】: