The possible git settings for line endings are:
- Checkout Windows-style, commit Unix-style
Git will convert LF to CRLF when checking out text files. When committing text files, CRLF will be converted to LF.
Git will not perform any conversion when checking out text files. When committing text files, CRLF will be converted to LF.
Git will not perform any conversions when checking out or committing text files.git config --global core.autocrlf true
- Checkout as-is, commit Unix-style
git config --global core.autocrlf input
- Checkout as-is, commit as-is
git config --global core.autocrlf false
Solution on Stackoverflow:
The proper way to get LF endings in Windows is to first set core.autocrlf to false:
Now git won’t do any line ending normalization.git config --global core.autocrlf false
If you want files you check in to be normalized, do this:
Settext=auto
in your .gitattributes for all files:
And set core.eol to lf:* text=auto
Now you can also switch single repos to crlf (in the working directory!) by runninggit config --global core.eol lf
After you have done the configuration, you might want git to normalize all the files in the repo. To do this, go to to the root of your repo and run these commands:git config core.eol crlf
If you now wano also normalize the files in your working directory, run these commands:git rm --cached -rf . git diff --cached --name-only -z | xargs -n 50 -0 git add -f
git ls-files -z | xargs -0 rm git checkout .
Personal opinion:
I set core.autocrlf to input, to make sure that the repo gets LF line endings always.
No comments:
Post a Comment