21Oct/100
git help: checkout new clean project copy
I love git. But throwing away changes you've already committed locally can be a real pain. A git guru buddy of mine ("Thanks, Mike!") provided a command line incantation worthy of sharing, since this is such a common problem frustrating git lovers around the world.
WARNING: this procedure deletes all files in the branch (project), even files not checked in. So you must first move all unchecked files to another directory.
From the command line (my example is on a mac) in your git repo root directory:
- Run git status. The output will list any "Untracked files" .
- Move all "Untracked files" you want to keep to another directory for safe keeping.
- Run git status again for review before running the following destructive procedure.
- Run these commands.
git checkout -f
git clean -f -d
git reset HEAD^^^ --hard
git checkout -f
git clean -f -d
git pull

