git reset
DestructiveReset state
git reset --hard <commit>
Moves HEAD/index back; --hard also discards working changes.
Examples
git reset --soft HEAD~1Undo last commit, keep changes
Syntax
git reset [--soft|--mixed|--hard] <ref>
Before you run it
--hard permanently discards uncommitted work.
Used when you see
Stuck in Git (push rejected / conflict)
4
See the whole flow →Roll back as last resortPrefer revert after sharing
Related commands
- git logView history
Check it once more before you run it
Some commands cannot be undone if one flag is wrong. An on-device reference works with no connection. Free to install, no ads.
Get it free on the App Store