git reset --hard HEAD~1

Category: Git - Core

git reset --hard HEAD~1

Undo last commit and discard all changes

Undoes the last commit AND discards all changes permanently. --hard is destructive — the changes are gone.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.