Git still shows “LF will be replaced by CRLF” warning when autocrlf is false and text is unspecified

Viewed 4216

I have a repo that will only ever be used on Windows. And I would prefer that source control does not modify the contents of my files in any way.

I set core.autocrlf to false in global settings and verified that no local repo override was present. I found that there was an existing .gitattributes file in my repo with * text=auto as the only entry. So I deleted the .gitattributes file. From reading the documentation, my understanding is that this should result in text being unspecified, and will follow the behavior set for core.autocrlf.

However, I still get the following error when I stage my files:

LF will be replaced by CRLF in MyProject/src/static/images/logo.svg.
The file will have its original line endings in your working directory.

If I understand correctly, there's something that still modifies my files. What is it and how can I stop it?

1 Answers

First, as I mentioned in "Windows git “warning: LF will be replaced by CRLF”, is that warning tail backward?", make sure to:

  • use a recent Git for Windows (more than 2.19 at the very least)
  • set git config --global core.autocrlf false (you have done so, as specified in your question: good)
    Since you don't have a .gitattributes file, there is no text attribute for svg files:

    If the text attribute is unspecified, Git uses the core.autocrlf configuration variable to determine if the file should be converted.

Second, check if an add --renormalize would help

git add --renormalize .
git commit -m "Introduce end-of-line final normalization if needed"
git push

Then check if a new clone of the repository would still ehibit the same message.


Note: the warning message has changed with Git 2.37 (Q3 2022).

Related