Git, adding files to repository gives fatal error for LF ->CRLF Git, adding files to repository gives fatal error for LF ->CRLF git git

Git, adding files to repository gives fatal error for LF ->CRLF


very new to this so setting core.autocrlf to false didn't make too much sense to me. So for other newbies, go to the config file in you .git folder and add:

[core]    autocrlf = false

under the [core] heading.


Trust the code editors to manipulate your line endings. Auto crlf should be false. Don't let source control get too smart. If don't need to have your source control tool to change your line endings, don't. This will hurt.

To reiterate from an accepted answer: "Unless you can see specific treatment which must deal with native eol, you are better off leaving autocrlf to false."

Also from the progit book at the end of the section on autocrlf:

"If you’re a Windows programmer doing a Windows-only project, then you can turn off this functionality, recording the carriage returns in the repository by setting the config value to false"

The only other help I can give is that if you take the other route, get familiar with vim -b which will show special characters such as the CR in MSysGit, and git show HEAD:path/to/your/file.txt which should show you the file in the way that git stored it.

Set core.whitespace cr-at-eol to have patches and diffs not highlight CRs as possible problematic whitespace.

Not worth the hassle. Store as-is.


The problem is probably occurring because you set Git to store files internally with crlf with the core.eol setting. When you add a file, Git is warning you it will change it to the internal format.

Git works best with lf line endings, so if possible always work with core.eol = lf.

This should explain when to use core.autocrlf, Why should I use core.autocrlf=true in Git?

You may also want to use core.safecrlf. Check git config --help for details on the settings.