With Git, how do I turn off the "LF will be replaced by CRLF" warning

GitLine EndingsGit Config

Git Problem Overview


With Git, when using the autocrlf = true flag, a warning is still given when line-endings are changed.

I understand what the warning is for, and how to turn off the line-ending flag, but how do I turn off the warning itself?

Git Solutions


Solution 1 - Git

You can turn off the warning with

git config --global core.safecrlf false

(This will only turn off the warning, not the function itself.)

Solution 2 - Git

You should use core.autocrlf input and core.eol input. Or just don't let git change the line endings at all with autocrlf false and get rid of highlighting of crlfs in diffs, etc with core.whitespace cr-at-eol.

Hope this helps

Solution 3 - Git

I used this way: > Save your current files in Git, so that none of your work is lost. > > git add . -u > git commit -m "Saving files before refreshing line endings" > > Remove every file from Git's index. > > git rm --cached -r . > > Rewrite the Git index to pick up all the new line endings. > > git reset --hard > > Add all your changed files back, and prepare them for a commit. This > is your chance to inspect which files, if any, were unchanged. > > git add . > # It is perfectly safe to see a lot of messages here that read > # "warning: CRLF will be replaced by LF in file." > > Commit the changes to your repository. > > git commit -m "Normalize all the line endings"

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

Solution 4 - Git

You're looking for the core.whitespace option (see git config --help for details).

You can set this option like so:

$ git config core.whitespace cr-at-eol

Solution 5 - Git

Funnily enough, I had applied both configs like explained here, and my .gitconfig file contained these 2 lines:

[core]
       autocrlf = false
       whitespace = cr-at-eol

Yet I got the warning. Now just to try I commented out both lines and the warning actually disappeared. No idea why I put them in the first place however...

Solution 6 - Git

Setting "core.safecrlf false" works. However, after I changed the value to 'true' The output changes from 'warning' to 'fatal' as shown below.

$ git add -A
warning: LF will be replaced by CRLF in .gitignore.
The file will have its original line endings in your working directory

$ git config --global core.safecrlf false

$ git reset

$ git config --global core.safecrlf true

$ git add -A
fatal: LF would be replaced by CRLF in .gitignore

$

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionsent-hilView Question on Stackoverflow
Solution 1 - GitChronialView Answer on Stackoverflow
Solution 2 - GitAdam DymitrukView Answer on Stackoverflow
Solution 3 - GitJulia ShestakovaView Answer on Stackoverflow
Solution 4 - GitPat NotzView Answer on Stackoverflow
Solution 5 - GitJean-Michel BernardView Answer on Stackoverflow
Solution 6 - GitPark JongBumView Answer on Stackoverflow