Reflog
In one line
The reflog is a local log of every HEAD and branch pointer movement — it is your safety net for recovering "lost" commits.
In simple words
The reflog (reference log) records every time HEAD or a branch pointer moves — every commit, checkout, reset, rebase, and merge. It is a local-only history of where your pointers have been.
The reflog is your safety net. If you accidentally git reset --hard and lose commits, they are still in the reflog. You can find the lost commit hash with git reflog and recover it with git reset --hard <hash>.
Reflog entries expire after a configurable period (default 90 days for unreachable commits, 30 days for reachable). Until then, commits referenced only by the reflog are not garbage collected. This makes the reflog a powerful recovery tool for undoing mistakes.
Example
# View the reflog
git reflog
# a1b2c3d HEAD@{0}: reset: moving to HEAD~1
# e5f6g7h HEAD@{1}: commit: Add feature
# Recover a lost commit
git reset --hard e5f6g7hreflog shows all pointer movements. Use it to recover lost commits.
Related terms
Related Resources
Related Lessons
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.