How to undo git reset --hard
May 2026
git reset --hard moves your branch and resets the working tree to match. It is useful, but it can wipe uncommitted work instantly.
If the work was committed
Run git reflog. Find the commit or branch state before the reset, then create a branch from it:
Reflog is often enough for commits because git still knows about those objects for a while.
If the work was uncommitted
This is the dangerous case. git reset --hard overwrites tracked files in the working tree. If the content was never committed or stashed, normal git recovery may not have a copy.
How oops prevents the loss
oops detects git reset --hard before it runs and creates a stash. If the reset was wrong, oops applies that stash back.
Preview before restoring
Use oops restore --plan to see the stash action before it changes your working tree. That is useful if you have made new edits since the reset.
Install
oops also covers git clean, other destructive terminal commands, and AI-agent-triggered resets.