Skip to content
The Git Crypt

/static/cripta/en/ossada/reflog/

Menu

GIT-001 · Rescue

git reflog

HEAD's logbook: the commit you think you lost is still down here.

Every time a reference moves — commit, reset, rebase, checkout — git notes the step in a local journal, the reflog. git reflog shows the whole trail, with addresses like HEAD@{2}: where HEAD was two moves ago.

It is the first step down into the crypt: after a hasty reset --hard or a rebase gone wrong, the old tip stays in the journal for months. Find the line, point the reset at it, and the disaster becomes an anecdote.

$ git reflog -3
3f1c2aa HEAD@{0}: reset: moving to HEAD~2
9e4d7b1 HEAD@{1}: commit: telemetria: fecha o painel
da0f3e6 HEAD@{2}: commit: hub /telemetria/
$ git reset --hard HEAD@{1}
HEAD is now at 9e4d7b1 telemetria: fecha o painel
The disastrous reset, undone by the logbook.