I’m trying to undo all changes since my last commit. I tried git reset --hard and git reset --hard HEAD after viewing this post. I responds with head is now at 18c3773… but when I look at my local source all the files are still there. What am I missing?
I’m trying to undo all changes since my last commit. I tried git reset
Share
This will unstage all files you might have staged with
git add:This will revert all local uncommitted changes (should be executed in repo root):
You can also revert uncommitted changes only to particular file or directory:
Yet another way to revert all uncommitted changes (longer to type, but works from any subdirectory):
This will remove all local untracked files, so only git tracked files remain:
To sum it up: executing commands below is basically equivalent to fresh
git clonefrom original source (but it does not re-download anything, so is much faster):Typical usage for this would be in build scripts, when you must make sure that your tree is absolutely clean – does not have any modifications or locally created object files or build artefacts, and you want to make it work very fast and to not re-clone whole repository every single time.