$ echo "* text=auto" >>.gitattributes $ rm .git/index # Remove the index to force Git to $ git reset # re-scan the working directory $ git status # Show files that will be normalized $ git add -u $ git add .gitattributes $ git commit -m "Introduce end-of-line normalization"Source: http://git-scm.com/docs/gitattributes#_end_of_line_conversion
Meanwhile, the people over at Github have a slightly different approach. (I'm wondering if
rm .git/indexfollowed by git reset is the same as git rm --cached -r.)
$ echo "* text=auto" >>.gitattributes $ git rm --cached -r . $ git reset --hard $ git add . $ git commit -m "Normalize all the line endings"Source: Refreshing a repository after changing line endings (Github)
The potential problem of the Github approach is that it would add files you might not want in your repository if your repository has any extra stuff in it, i.e. if doing a git status before their procedure shows any files not in the repository.
What's very interesting about the Github approach is that it's very similar to my method for removing all files from a repository that you'd actually like to ignore, except that my steps are missing the git reset --hard command:
$ git rm --cached -r . $ git add .gitignore $ git add . $ git commit -m "Remove ignored files."
One thing I'm not sure of is the difference between
git reset vs
git reset --hard
git reset --hardin the Github approach. I'll have to think about that another time. :)