Skip to content

Reflog

Medium — good to knowGit & Version Control

ELI5 - The Vibe Check

Git's reflog is the secret undo history that survives even after you think you've deleted something forever. Force-pushed over your only copy of three days of work? Reset hard onto the wrong commit? Reflog remembers every place HEAD has pointed, even the erased-looking ones, for weeks. It's the check-the-recycling-bin-before-you-panic move.

Real Talk

The reflog is a local, per-repository log of every update to HEAD and branch refs, including commits that become unreachable from any branch after a reset, rebase, or force-push. It is never shared via push or pull and entries expire on a timer (90 days by default for reachable ones, 30 for unreachable ones), but within that window it can recover almost any lost commit via git reflog followed by git reset or git cherry-pick.

Show Me The Code

$ git reflog
a1b2c3d HEAD@{0}: reset: moving to HEAD~3
e4f5g6h HEAD@{1}: commit: fix auth bug
$ git reset --hard e4f5g6h

When You'll Hear This

"I force-pushed over my branch, but the reflog still has it." / "Check the reflog before you assume the commit is gone forever."

Made with passive-aggressive love by manoga.digital. Powered by Claude.