# From the root of your repository remove everything from the index
git rm --cached -r .
# Change the autocrlf setting of the repository (you may want
# to use true on windows):
git config core.autocrlf input
# Re-add all the deleted files to the index
# (You should get lots of messages like:
# warning: CRLF will be replaced by LF in <file>.)
git diff --cached --name-only -z | xargs -0 git add
git commit -m "Fixed crlf issue"
# If you're doing this on a Unix/Mac OSX clone then optionally remove
# the working tree and re-check everything out with the correct line endings.
git ls-files -z | xargs -0 rm
git checkout .
# Set the default behavior, in case people don't have core.autocrlf set.
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
# Declare files that will always have CRLF line endings on checkout.
*.sln text eol=crlf
# Denote all files that are truly binary and should not be modified.
you’ll notice that files are matched–*.c, *.sln, *.png–, separated by a space, then given a setting–text, text eol=crlf, binary. We’ll go over some possible settings below.
Git will handle the files in whatever way it thinks is best. This is a good default option.
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. For example, here is a Windows project that enforces CRLF line endings.
Git will always convert line endings to LF on checkout. You should use this for files that must keep LF endings, even on Windows. For example, here is a project that enforces LF line endings.
Git will understand that the files specified are not text, and it should not try to change them. The binary setting is also an alias for -text -diff.