Theory

Updated

October 30, 2026

Theory: The Reflog is a Local Journal of Names

Every time a ref in this clone moves, Git can append a line to that ref’s log. It is not replicated. It is not a backup of other clones.

Invariants

  1. HEAD and each branch can have a reflog.
  2. Default expire is on the order of 30 days (gc.reflogExpire).
  3. HEAD@{1} is “where HEAD was last time,” not “parent commit.”
  4. Recovering a deleted branch is git switch -c name <hash-from-reflog>.
main moved C → D → E
reflog  E HEAD@{0}
        D HEAD@{1}
        C HEAD@{2}     (local only)

What can break

  • Expecting a teammate’s reflog to contain your amended commit.
  • gc --prune=now after expire.

How to read this chapter

How it works, recover a branch, the 30-day window, step-by-step scenarios.