JAEN

Git

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 commit
  • git 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

Stuck in detached HEAD
3
If you already moved away, recover via reflog
See the whole flow →
Broke history with reset/rebase
1
Find the pre-disaster commit in reflogHEAD@{n} addresses any prior state directly.
See the whole flow →

Related commands

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