How do I force git to checkout the master branch and remove carriage returns after I've normalized files using the "text" attribute?
Ahah! Checkout the previous commit, then checkout the master.
git checkout HEAD^
git checkout -f master
As others have pointed out one could just delete all the files in the repo and then check them out. I prefer this method and it can be done with the code below
git ls-files -z | xargs -0 rm
git checkout -- .
or one line
git ls-files -z | xargs -0 rm ; git checkout -- .
I use it all the time and haven't found any down sides yet!
For some further explanation, the -z
appends a null character onto the end of each entry output by ls-files
, and the -0
tells xargs
to delimit the output it was receiving by those null characters.