git reflog
Shows a log of all reference updates (e.g., commits, checkouts, rebases), useful for recovering lost commits.
Syntax
git reflog [show] [<options>] [<ref>]
Options
- show: Shows the reflog for a reference (default subcommand)
- expire: Prunes old reflog entries
- --date=<format>: Shows dates in the specified format (relative, iso, short)
- -n <number>: Limits the number of entries shown
Example
git reflog git reflog show main git reflog --date=relative
Tip
Reflog is your safety net — use it to find and recover lost commits after a bad rebase or reset.