You think commits were lost and the reflog entry has expired. Can anything still be found?
AdvancedScenarioUndoing Mistakes
Answer
Situation read → If gc has not pruned the objects yet, they exist as dangling commits even without reflog entries.
What I'd do →
git fsck --lost-found --no-reflogslists dangling commits and blobs.- Inspect:
git show <sha>orgit log -1 <sha>. - Rescue:
git branch recovered <sha>. - Stop all
git gcactivity:git config gc.auto 0.
Why → Pruning happens only after gc.pruneExpire (default 2 weeks) for unreachable objects.
Interview tip → Also ask whether a teammate, CI runner or fork has a copy.
More on Undoing Mistakes
You committed on `main` when you meant to be on a feature branch. Nothing is pushed. Fix it.BeginnerYou made a typo in your last commit message and have not pushed.BeginnerA bad commit is already on shared `main`. Others have pulled it. How do you undo it?IntermediateYou ran `git reset --hard` and lost uncommitted-then-committed work. Can you get it back?IntermediateYou need to revert a merge commit on `main`. `git revert` says "commit is a merge but no -m option was given".IntermediateYou deleted a local branch with unmerged work by mistake.Beginner