A Real, Destructive Mistake
Three real commits, instantly gone from the branch — no confirmation, no warning. The working directory is overwritten to match, too.
The One-Command Undo
git reset --hard HEAD@{1}
HEAD@{1} means "one real step back in HEAD's own reflog" — immediately after the bad reset, that is exactly the good commit from right before it. No hash to look up, no grep required.
Confirming the Real Recovery
All three real commits, back exactly where they were, plus whatever came before them.
git reset --hard HEAD~3 is a real, genuinely destructive command — it moves the branch pointer back three commits and overwrites the working directory to match, with no confirmation. Three real recipes, just committed, disappear from the branch instantly.
But reset --hard, like every ref-moving command, is itself recorded in reflog before it happens. HEAD@{1} always means "wherever HEAD was, one real step before its most recent move" — which, immediately after a bad reset, is exactly the good state from right before it. No searching required.
HEAD@{1}
Reflog's own relative addressing — "one real step back from HEAD's current reflog position," regardless of what kind of operation caused that move. Confirmed directly in this lab: run immediately after a bad reset --hard, it pointed exactly at the good state from right before it.
Takeaways
- git reset --hard is genuinely destructive to the branch pointer and working directory, with no confirmation
- The commits themselves are never deleted by reset --hard — only the branch pointer moves
- HEAD@{1} means "one real step back," regardless of what operation caused the last move — run immediately after a mistake, it undoes exactly that mistake
- The longer other operations happen after a bad reset, the further back the right reflog entry gets — recover as soon as the mistake is noticed