Reflog
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."
Related Terms
Detached HEAD
Detached HEAD is the state you end up in when you check out a specific commit instead of a branch, and git politely warns you that anything you commit here...
Git Bisect
Git bisect is a binary search for bugs.
Rebase
Rebase is like rewriting history.
Reset
Reset is like pressing undo on your commits.