warning: LF will be replaced by CRLF.
Depending on the editor you are using, a text file with LF wouldn’t necessary be saved with CRLF: recent editors can preserve eol style. But that git config setting insists on changing those…
Simply make sure that (as I recommend here):
git config --global core.autocrlf false
windows git “LF will be replaced by CRLF”
Is this warning tail backward?
No: you are on Windows, and the
git config help page does mention
Use this setting if you want to have
CRLFline 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
repo / \ crlf->lf lf->crlf / \
warning: (If you check it out/or clone to another folder with your current
core.autocrlfconfiguration,) LF will be replaced by CRLF
The file will have its original line endings in your (current) working directory.
As mentioned in
git-for-windows/git issue 1242:
I still feel this message is confusing, the message could be extended to include a better explanation of the issue, for example: “LF will be replaced by CRLF in
file.jsonafter removing the file and checking it out again”.
Note: Git 2.19 (Sept 2018), when using
core.autocrlf, the bogus “LF will be replaced by CRLF” warning is now suppressed.
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);
And that last
renormalize_buffer() is only called by
So I suspect this conversion happens on a
git commit only if said commit is part of a merge process.
Note: with Git 2.17 (Q2 2018), a code cleanup adds some explanation.
convert_to_git(): safe_crlf/checksafe becomes int conv_flags
checksafe parameter defined what should happen if the EOL conversion (
CRLF --> LF --> CRLF) does not roundtrip cleanly.
In addition, it also defined 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