I cloned a UNIX-oriented repository, and git promptly converted CR to CRLF in all text files, which caused some problems down the line. Here’s how to revert to the original line endings:
1. Make sure there is no unsaved work – commit or stash anything that’s pending.
2. At the root of the repository create a file called .gitattributes
and put the following text in it:
* -crlf
This ensures that no files are subject to the line endings conversion.
3. Clear your index. This will not physically remove any files, but will update git internal data structures (don’t forget that final dot):
git rm --cached -r .
4. Rebuild your working directory from the repository using new rules:
git reset --hard
Voila. Enjoy your untouched line endings.