git reflog: entry expired and pruned
Quick summary
You tried to recover a commit via git reflog but the entry was already pruned by git gc — the commit hash is no longer in the reflog.
Why this happens
git gc ran automatically and pruned reflog entries older than the configured gc.reflogExpire (default 90 days)
You ran git reflog expire --expire=now or git gc --prune=now which aggressively removed all old reflog entries
The reflog was manually cleared or the repository was cloned fresh without the original reflog history
Minimal example
git reflog # entry for abc123 is gone after git gc --prune=now
git reset --hard abc123 # fatal: ambiguous argumentgit fsck --lost-found # find dangling commit objects
git reset --hard <found-hash> # recover from lost-found if presentgit fsck --lost-found searches the object database for dangling commits that have not yet been pruned from disk, offering a last-resort recovery path.
How to diagnose
Run git reflog show <branch> to check if the entry still exists in the branch reflog
Use git fsck --lost-found to search for dangling commits that may still be recoverable from the object store
Check git config gc.reflogExpire and gc.reflogExpireUnreachable to understand the pruning schedule
How to fix
Search for the commit with git fsck --lost-found and recover it from .git/lost-found if the object still exists
If a remote still has the commit, fetch it with git fetch origin <commit-hash> to restore the object locally
If the commit is truly gone, reconstruct the work from backups or by re-applying known changes manually
How to prevent
Increase gc.reflogExpire to a longer duration or set git config gc.auto 0 to disable automatic garbage collection
Tag important commits immediately with git tag to prevent them from being pruned as unreachable
Related Resources
Related Glossary
Related Lessons
- git reflog
Learn how to recover lost commits.