See recent HEAD history
git reflog
Recover a commit
git checkout
git checkout -b rescue
Find dangling commits
git fsck —unreachable
git fsck —lost-found
Inspect a dangling commit
git show
List dangling commits
git fsck —lost-found
| grep “dangling commit”
Before garbage collection
Git usually keeps unreachable commits for:
- ~30 days in reflog
- ~90 days before pruning
After GC/prune:
- Commit may be permanently lost