I know that Git tracks changes I make to my application, and it holds on to them until I commit the changes, but here's where I'm hung up:
When I want to revert to a previous commit I use:
git reset --hard HEAD
And Git returns:
HEAD is now at 820f417 micro
How do I then revert the files on my hard drive back to that previous commit?
My next steps were:
git add .
git commit -m "revert"
But none of the files have changed on my hard drive...
What am I doing right/wrong?
This question is related to
git
head
git-reset
git-revert
WARNING:
git clean -f
will remove untracked files, meaning they're gone for good since they aren't stored in the repository. Make sure you really want to remove all untracked files before doing this.
Try this and see git clean -f
.
git reset --hard
will not remove untracked files, where as git-clean
will remove any files from the tracked root directory that are not under Git tracking.
Alternatively, as @Paul Betts said, you can do this (beware though - that removes all ignored files too)
git clean -df
git clean -xdf
CAUTION! This will also delete ignored filesSource: Stackoverflow.com