6

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?

Hele
  • 1,558
  • 4
  • 23
  • 39

1 Answers1

4

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).

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • 1
    Sometimes, svg can benefit from eol conversion (https://github.com/zellwk/zellwk.com/issues/17), but I usually avoid eol conversion as much as possible. – VonC Aug 15 '20 at 19:35
  • Updating Git to the latest 2.28 resolved my issue. Git had been installed on my machine by Visual Studio and I wrongly assumed that VS' update mechanism would keep Git up to date. I was still using version 2.17.2. From your referenced answer it looks like this was a bogus warning. I had not found your answer as my search terms returned other results that weren't helpful. Thanks a bunch! – Hele Aug 15 '20 at 22:06