Git Reflog and Recovery Cheat Sheet/Set unreachable reflog retention

Control retention for entries that are no longer reachable.

Section: Safety and Maintenance

Set unreachable reflog retention

bash
bash
git config --global gc.reflogExpireUnreachable 30.days
Explanation

Important if you often rewrite history and want a wider window for recovery.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Safety and Maintenance
Set default reflog retention
Customize how long normal reflog entries are retained.
OpenIn sheetbashsame section
Run aggressive pruning now
Force garbage collection and immediate pruning.
OpenIn sheetbashsame section
Inspect loose objects and packing state
Check repository object counts and size details.
OpenIn sheetbashsame section
Show reflog
List recent local HEAD and branch movements.
OpenIn sheetbash2 tag match
Restore branch to a reflog entry
Move the current branch back to a previous recorded state.
OpenIn sheetbash2 tag match
Show reflog as a log
Browse reflog entries using log formatting.
OpenIn sheetbash2 tag match