Git · History and recovery

git reset --hard

Moves the branch and discards working-tree changes. This can destroy uncommitted work.

Syntax
git reset --hard <ref>

Example

Example
git reset --hard HEAD~1

More in this group

git clean git reflog git reset --mixed git reset --soft git restore git revert git stash git stash apply vs pop

Learn this in the course

Reference pages are the quick answer. The course explains the why, shows the full example and ends with a challenge.

Open the course