Skip to content

Instantly share code, notes, and snippets.

@phantom42
Last active August 29, 2015 14:23
Show Gist options
  • Save phantom42/0cf24bbd90a2b0c67b98 to your computer and use it in GitHub Desktop.
Save phantom42/0cf24bbd90a2b0c67b98 to your computer and use it in GitHub Desktop.
how to deal with line crlf issues in git
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto
# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.c text
*.h text
# 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.
*.png binary
*.jpg binary
-- based on this answer: http://stackoverflow.com/a/14129301/1147918
git ls-files -m | xargs -i git update-index --assume-unchanged "{}"
-- instructions: https://help.github.com/articles/dealing-with-line-endings/, based on http://stackoverflow.com/a/1511273/1147918
git config --global core.autocrlf true
git add . -u
git commit -m "Saving files before refreshing line endings"
git rm --cached -r .
git reset --hard
git add .
git commit -m "Normalize all the line endings"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment