Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git config core.autocrlf is true, but I'm still getting a warning?

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 core.autocrlf set to true. However, contrary to what other threads say (e.g., this), I am still getting this warning:

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 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?

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.

like image 316
lfk Avatar asked Dec 15 '25 05:12

lfk


1 Answers

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.
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)

If you have files that need conversion, use an eol directive in a .gitattributes file.
Make sure to use the latest Git for Windows though: there was a bug in Git 2.10.

That being said, if you still want to use core.autocrlf, see "Make Git “LF will be replaced by CRLF” warnings go away": you can remove your index and checkout again.

like image 132
VonC Avatar answered Dec 16 '25 18:12

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!