Depending on the editor you are using, a text file with LF wouldn't necessarily be saved with CRLF: recent editors can preserve eol style. But that git config setting insists on changing those...
Simply make sure that :
git config --global core.autocrlf false
That way, you avoid any automatic transformation, and can still specify them through a .gitattributes file and core.eol directives.
windows git "LF will be replaced by CRLF"
Is this warning tail backward?
No: you are on Windows, and the git config page does mention to 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.
As described in "git replacing LF with CRLF", it should only occur on checkout (not commit), with core.autocrlf=true.
repo / \ crlf->lf lf->crlf / \
That specific warning "LF will be replaced by CRLF" comes from convert.c#check_safe_crlf():
if (checksafe == SAFE_CRLF_WARN) warning("LF will be replaced by CRLF in %s. The file will have its original line endings in your working directory.", path); else /* i.e. SAFE_CRLF_FAIL */ die("LF would be replaced by CRLF in %s", path); It is called by convert.c#crlf_to_git(), itself called by convert.c#convert_to_git(), itself called by convert.c#renormalize_buffer() and that last renormalize_buffer() is only called by merge-recursive.c#blob_unchanged(). So I suspect this conversion happens on a git commit only if said commit is part of a merge process. When calling convert_to_git(), the checksafe parameter defines what should happen if the EOL conversion (CRLF --> LF --> CRLF) does not roundtrip cleanly. In addition, it also defines if line endings should be renormalized (CRLF --> LF) or kept as they are.
checksafe was an safe_crlf enum with these values:
SAFE_CRLF_FALSE: do nothing in case of EOL roundtrip errors SAFE_CRLF_FAIL: die in case of EOL roundtrip errors SAFE_CRLF_WARN: print a warning in case of EOL roundtrip errors SAFE_CRLF_RENORMALIZE: change CRLF to LF SAFE_CRLF_KEEP_CRLF: keep all line endings as they are