Solving Git LF will be replaced by CRLF
If you are using Window machine your new line is a character CR LF
but for Mac and Linux is LF
This make git status show every file change. All files in repos are in red.
when you try to see the diff
warning: LF will be replaced by CRLF in index.js. The file will have its original line endings in your working directory.
What we want is onlyCRLF
to make the code work on our Window workspace andLF
elsewhere.
The fix is by use autocrlf
git config --global core.autocrlf true
You won’t see it work unless you delete and clone
the repos again or restart the index by
git add --renormalize .
What does it do?
From the git document here.
“Git can handle this by auto-converting CRLF
line endings into LF
when you add a file to the index, and vice versa when it checks out code onto your file system.”
In short, when code enter your machine git add CR
. When you add file by git, git strip off CR
.