I made a lot of unhelpful changes, and would like to revert to the state my repo was in before any of the changes.
Is there a git command for doing that?
Thanks!
First, to revert changes to tracked files:
git reset --hard HEAD
git reset
alone resets the index; adding --hard
resets the working copy as well. If you've already committed, specify a different commit to reset to - eg, HEAD^
to revert to the parent commit of HEAD
(ie, to remove the latest commit).
Next, to delete all untracked files:
git clean -dfx
-d
tells it to delete directories, -f
forces it to actually do the delete, and -x
skips .gitignore
d files.