Git Academy

Intermediate · 5 min read

The reflog, your safety net

Almost nothing committed is ever really lost. Here is how to find it.

What it records

Each time HEAD moves (commit, checkout, reset, rebase, merge), Git writes a line in the reflog. It is local to your machine and kept about 90 days by default.

Safe
$ git reflog

Going back in time

Each entry has a name like HEAD@{2}. Create a branch on it to inspect it safely before changing anything.

Safe
$ git branch rescue HEAD@{2}