Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git add throws warning "CRLF will be replaced by LF in <file-name>"

I started working on a Xamarin crossplatform development recently. While some of devs in my team are using Mac for development (with Visual Studio for Mac), others are using Windows (with Visual Studio 2017). We use git/github as our code repository/version control system.

After I did some changes and added some new files, I issued git add . to stage all my changes but I got warnings like this

warning: CRLF will be replaced by LF in <file-name>.
The file will have its original line endings in your working directory

I checked my git config and core.autocrlf=input which to my understanding and according to documentation here https://git-scm.com/book/en/v2/Customizing-Git-Git-Configuration, is correct setting for Mac.

However, I am unsure about the warning above since I have never seen it before. I find it even more confusing since not all of files I added are showing this warning but only some.

I have read numerous posts about this issue but none seam to clearly explain if these warnings can or cannot be ignored. Or if they need to be fixed and how to fix them for teams that use both Windows and MacOS like mine team does.

Do I need to worry about this warning and what does it exactly mean for teams like mine working on both Windows and MacOS machines?

like image 396
cd491415 Avatar asked Nov 13 '18 23:11

cd491415


1 Answers

I would still recommend:

git config core.autocrlf false
git add --renormalize .
git commit -m "Do not touch eol"

If you can, avoid Git making any change to your eol, and work with editors which respect the eol of the file being edited.

like image 143
VonC Avatar answered Oct 23 '22 17:10

VonC