warning: LF will be replaced by CRLF.
Depending on which editor you use, a text file with LF will not necessarily be saved with CRLF: recent editors may preserve the eol style. But this git config setting insists on changing these ...
Just make sure (as I recommend here ):
git config --global core.autocrlf false
This way you avoid any automatic conversions and you can specify them with the .gitattributes file of the core.eol directives .
Windows Git "LF will be replaced by CRLF"
Is this warning tail back?
No: you are on Windows and the git config help page is not mentioned
Use this option if you want CRLF line endings in your working directory even if there are no normalized line endings in the repository.
As described in " git replacing LF with CRLF ", this should only happen when fetching (not commit), with core.autocrlf=true .
repo / \ crlf->lf lf->crlf / \
As mentioned in XiaoPeng's answer , this warning is similar:
warning: (If you check it or clone to another folder with the current core.autocrlf configuration,) LF will be replaced by CRLF
The file will have the original line endings in your (current) working directory.
As mentioned in git-for-windows/git release 1242 :
I still feel this message is confusing, the message can be expanded to include a better explanation of the problem, for example: "LF will be replaced with CRLF in file.json after deleting the file and checking it again."
Note: Git 2.19 (September 2018) when core.autocrlf used, core.autocrlf “LF will be replaced by CRLF” is now suppressed .
As Quailar rightly comments , if the conversion occurs at commit , then only in LF .
This particular 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 die("LF would be replaced by CRLF in %s", path);
It is called convert.c#crlf_to_git() , it is called convert.c#crlf_to_git() itself, convert.c#convert_to_git() convert.c#renormalize_buffer() .
And this last renormalize_buffer() is only called using merge-recursive.c#blob_unchanged() .
Therefore, I suspect that this conversion occurs in git commit only if the specified commit is part of the merge process.
Note: in Git 2.17 (Q2 2018), clearing the code adds some clarification.
See Commit 8462ff4 (January 13, 2018) of Torsten Begershausen ( tboegi ) .
(Combined by Junio K Hamano - gitster - in commit 9bc89b1 , February 13, 2018)
convert_to_git (): safe_crlf / checkafe becomes int conv_flags
When calling convert_to_git() the checksafe parameter determined what should happen if the EOL conversion ( CRLF --> LF --> CRLF ) does not perform purely cyclic processing.
In addition, he also determined whether to renormalize line endings ( CRLF --> LF ) or leave them as they are.
checkafe was a safe_crlf listing with the following 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
Note that the regression introduced in 8462ff4 (" convert_to_git() : safe_crlf/checksafe becomes int conv_flags ", 2018-01-13, Git 2.17.0) as early as the Git 2.17 loop forced autocrlf rewrite so that autocrlf warned despite setting safecrlf=false ,
See Commit 6cb0912 (June 04, 2018) by Anthony Sottil ( asottile ) .
(Combined Junio C Hamano - gitster - in commit 8063ff9 , June 28, 2018)