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?
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. You should use this for files that must keep LF endings, even on Windows.
In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have an LF.
autocrlf . This is a similar approach to the attributes mechanism: the idea is that a Windows user will set a Git configuration option core. autocrlf=true and their line endings will be converted to Unix style line endings when they add files to the repository.
autocrlf = true This means that Git will process all text files and make sure that CRLF is replaced with LF when writing that file to the object database and turn all LF back into CRLF when writing out into the working directory.
First, as I mentioned in "Windows git “warning: LF will be replaced by CRLF”, is that warning tail backward?", make sure to:
git config --global core.autocrlf false
(you have done so, as specified in your question: good).gitattributes
file, there is no text attribute for svg
files:
If the
text
attribute is unspecified, Git uses thecore.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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With