LF will be replaced by CRLF in git -the file will have its original line endings what does this mean?
-
possible duplicate of [git replacing LF with CRLF](http://stackoverflow.com/questions/1967370/git-replacing-lf-with-crlf) – Alex Tartan May 29 '15 at 07:08
-
Add some context. Are you quoting? Where from? – reto May 29 '15 at 07:10
2 Answers
This usually happens when you are on Windows and either core.autocrlf is set to true, or the .gitattributes contains directives to perform line ending normalizations.
The way line ending normalization works (on a Windows machine) is that when you commit a file, git replaces every CRLF with a LF, and when you checkout a file, git replaces every LF with a CRLF. Normally this is all transparent to you, and all you ever see is CRLFs in your working directory. However, if you somehow create a file with just LFs in your working directory, here is what will happen:
- When committing, git will "convert" the LFs to LFs, i.e. do nothing
- When checking out, git will convert the LFs to CRLFs
The upshot is, you end up creating a file with just LFs, but from then on you always see CRLFs in it. That is what git is warning you about.
Assuming that it is a text file we are talking about, you can go ahead and ignore this warning. However, if it is a binary file, it means that git is going to attempt to do line normalizations on it, which will corrupt the file. In that case you need to check your .gitattributes file and see why this is happening.

- 17,443
- 4
- 47
- 54
In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have an LF. To avoid this just write this in from you project root folder.
git config core.autocrlf false

- 300
- 1
- 10