Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding the warning "LF will be replaced by CRLF"

I have already read the Git documentation discussed in this answer (LF will be replaced by CRLF in git - What is that and is it important?) but I don't understand what it means for my situation.

I have LF files which were introduced by a tool into my git checkout on Windows. When I tried to commit them, I got the warning warning: LF will be replaced by CRLF in [file].

git config core.autocrlf is true on this machine. I committed anyway. The line endings on Windows are still LF. Then I checked out the file on a Linux machine where git config core.autocrlf doesn't appear to be set. I inspected the line endings there, and they were also LF.

So what I don't understand is, WHERE is it saying that LF will be replaced by CRLF? Does it mean, next time I pull a change to the file (which is committed by somebody from another machine) the line endings will be converted?

Also - what line endings does Git use in its internal repo?

like image 756
Stephen Avatar asked Mar 16 '18 15:03

Stephen


1 Answers

I guess you'd say that internally git prefers LF. To say it "uses LF internally" isn't quite accurate, because you can configure it not to. (For example, if everyone on your team uses Windows so you all turn eol normalization off, then git will have the CRLF eol markers.)

What the warning is saying is, you're checking this in with linefeed normalization on, but it already has LF. If you check it back out with autocrlf in effect, you'll get CRLF endings. BUT since you have a local copy in your work tree, it will stay as it is.

So "where" would typically be any new repo using autocrlf=true ; or any colleague's repo if checking out from git creates the file for them locally

like image 170
Mark Adelsberger Avatar answered Sep 17 '22 13:09

Mark Adelsberger