Skip to content
Recovery

Undo a hard reset

Your agent ran `reset --hard`. The commits are still there.

The reflog records every position HEAD and each branch has held, with a note of what moved it. It is local, it is not pushed, and it is the first place to look when something has vanished.

`HEAD@{1}` is where HEAD was one move ago. `git reset --hard HEAD@{1}` therefore undoes the last thing that moved it — including a reset.

This works because moving a branch does not delete commits. Nothing is removed from the object store until a garbage collection, and until then everything is one command away.

Commands in this lesson

git reflog
Show every position a ref has held, and what moved it there
git reset --hard
Move the branch and overwrite the index and your files — the one that loses work
No account, no backend. Everything you do stays in this browser.liter8.sh