根据这个问题,我知道git中的core.autocrlf = true会导致CRLF转换为LF.
但是,当我键入:git config core.autocrlf
我明白了:假
但是,当我暂存已经在repo中的已修改文件时,我仍然会收到以下警告:
Warning: CRLF will be replaced by LF in File1.X.
The file will have its original line endings in your working directory.
Run Code Online (Sandbox Code Playgroud)
我的猜测是文件的repo副本已经设置为"autocrlf = true".
问题:A.如何查询文件或git仓库是否已经强制AutoCrlf?B.如何关闭autocrlf?
小智 7
Git允许您使用.gitattributes文件在每个存储库的基础上覆盖您的全局设置.您将它放在存储库的根目录中,并成为作为存储库的一部分提交的文件.我怀疑你的情况会发生这种情况.
Github有一个很好的页面:https://help.github.com/articles/dealing-with-line-endings
简而言之,您可以使用text属性设置特定文件扩展名的行结尾.例如,强制sln文件到CRLF将需要.gitattributes文件中的以下行:
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
Run Code Online (Sandbox Code Playgroud)