Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git Warning: LF will be replaced by CRLF

Tags:

git

git-gui

I am using Git gui. I see this error for several files in a folder. I have two choice buttons - Unlock index and Continue. I don't understand what the buttons do. I saw other SO posts which tell me to ignore the warning, but they don't mention how to do it in GUI. Please tell me which button I should press and why. Thanks.

Here is the error message sample -

Updating the Git index failed. A rescan will be automatically started to resynchronize git-gui.

warning: LF will be replaced by CRLF in gen/com/click4tab/pustakalpha/BuildConfig.java. The file will have its original line endings in your working directory. (repeat above messages for other files)

like image 447
james Avatar asked Jul 15 '14 16:07

james


People also ask

What is warning LF will be replaced by CRLF in git?

This isn't an error, simply a warning that the files that will be committed are different than the files you saved. The default behavior for git on windows is to convert LF to CRLF, because some editors in Windows don't know how to handle LF (e.g. Notepad would ignore them and display everything as one line of text).

How do I turn off LF will replace by CRLF?

Fix LF Will Be Replaced by CRLF Warning in Git If you wish to use the project under Windows only, the flag should be set to false . However, in Unix-based OS, you can disable the core. autocrlf per our need. The command will give output of true or false or input , and you can make changes according to your need.

Does git use LF or CRLF?

This is a good default option. text eol=crlf Git will always convert line endings to CRLF on checkout. You should use this for files that must keep CRLF endings, even on OSX or Linux. text eol=lf Git will always convert line endings to LF on checkout.

What's the difference between LF and CRLF?

CR = Carriage Return ( \r , 0x0D in hexadecimal, 13 in decimal) — moves the cursor to the beginning of the line without advancing to the next line. LF = Line Feed ( \n , 0x0A in hexadecimal, 10 in decimal) — moves the cursor down to the next line without returning to the beginning of the line.


4 Answers

Set up the CRLF and the problem will "disappear"

# Option 1:
git config --global core.autocrlf false

# Option 2:
`git config --global core.safecrlf false`

https://help.github.com/articles/dealing-with-line-endings

like image 195
CodeWizard Avatar answered Oct 07 '22 20:10

CodeWizard


It is not autocrlf matters, but safecrlf. Use below command to suppress the warnings.

git config --global core.safecrlf false

autocrlf is to control whether transform line endings when add/checkout, while safecrlf is to control whether warn users when doing such transformations.

like image 21
lxvs Avatar answered Oct 07 '22 22:10

lxvs


Soo, i'm have that problem too. I fix it, simple, using by IDE. have a problem

Use IDE (intellij idea). use IDE

And then after use IDE.. no problem) no problem)

like image 4
Marty McAir Avatar answered Oct 07 '22 20:10

Marty McAir


To add onto @Code Wizard's solution here: https://stackoverflow.com/a/24770798/19037789 ,

You can also run the following command to set your CRLF locally, only to the specific project you're working on:

git config --local core.autocrlf false
like image 2
WilliamSanchez Avatar answered Oct 07 '22 20:10

WilliamSanchez