Git

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
Roll back as last resortPrefer revert after sharing
See the whole flow →
Broke history with reset/rebase
2
Reset back to that state
See the whole flow →
Undo a bad commit/push
3
If strictly local, reset is an option
See the whole flow →

Related commands

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