git reflog
CautionHEAD history (lifesaver)
git reflog
Every HEAD move is recorded — recover 'lost' commits after reset --hard or a bad rebase.
Examples
git reflogFind a lost commitgit reset --hard HEAD@{2}Restore an earlier state
Syntax
git reflog [show] [branch]
Before you run it
Viewing is safe; recover with care.
Used when you see
Broke history with reset/rebase
1
See the whole flow →Find the pre-disaster commit in reflogHEAD@{n} addresses any prior state directly.
The same reference, with no signal at all
Every command on this site, held on your device. The app adds 632 more: 1,510 commands and 120 fix flows, searchable with no connection. Free to install, no ads (some content is a one-time purchase).
Get it free on the App Store