git config core.autocrlf是真的,但我仍然收到警告? [英] git config core.autocrlf is true, but I'm still getting a warning?
问题描述
据我所知,Windows使用CRLF,并且最好让Git在提交之前将行结尾更改为LF,并在签出时将其更改回CRLF。出于这个原因,我将 core.autocrlf
设置为true。然而,与其他线索所说的相反(例如,),我仍然得到这个警告:
警告:LF将是由[FILE_NAME]中的CRLF取代。
该文件的原始行结束符将在您的工作目录中。
首先,我认为将 core.autocrlf
为true应该停止这些警告。其次,Git是否应该在提交时将LF转换为CRLF,而不是其他方式?
有趣的是,我只提交了很多文件, (.csproj和.cs)。
PS我在Windows上使用Git Bash。
让Git改变行尾是个好习惯在提交之前转换为LF,并在退出时返回CRLF。
它是核心,但不是。 autocrlf。 如果您的文件需要转换,请使用 这就是说,如果你仍然想使用 I understand that Windows uses CRLF and that it's good practice to let Git change line endings to LF before committing and back to CRLF when checking out. For that reason, I have warning: LF will be replaced by CRLF in [FILE_NAME].
The file will have its original line endings in your working directory. Firstly, I thought setting Interestingly, I just committed many files and got this warning for only two of them (a .csproj and a .cs). P.S. I am using Git Bash on Windows. that it's good practice to let Git change line endings to LF before committing and back to CRLF when checking out. It is, but not with core.autocrlf. If you have files that need conversion, use an That being said, if you still want to use 这篇关于git config core.autocrlf是真的,但我仍然收到警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
您应该始终将core.autocrlf设置为false,因为它会尝试为所有文件(包括非文本文件)转换eol(行尾) p>
eol
中。指令放在
.gitattributes
文件
确保使用最新的Git for Windows 虽然:有一个 Git 2.10中的bug 。
core.autocrlf
,请参阅制作GitLF将被CRLF取代警告消失:您可以删除您的索引并重新签出。core.autocrlf
set to true. However, contrary to what other threads say (e.g., this), I am still getting this warning:
core.autocrlf
to true was supposed to stop these warnings. Secondly, isn't Git supposed to convert LF to CRLF when committing, not the other way around?
You should always set core.autocrlf to false, as it would try and convert eol (end of line) for all files (including non-text file)eol
directive in a .gitattributes
file.
Make sure to use the latest Git for Windows though: there was a bug in Git 2.10.core.autocrlf
, see "Make Git "LF will be replaced by CRLF" warnings go away": you can remove your index and checkout again.