You dropped a stash entry accidentally and need it back.
AdvancedScenarioUndoing Mistakes
Answer
Situation read → A dropped stash is an unreachable commit; Git printed its SHA when you dropped or popped it.
What I'd do →
- If you saw
Dropped refs/stash@{0} (abc123...), rungit stash apply abc123. - Otherwise search dangling commits:
git fsck --no-reflogs --unreachable | awk '/commit/ {print $3}' \
| xargs git log --no-walk --format='%h %ad %s' --date=short
- Look for "WIP on <branch>" messages and apply the right one with
git stash apply <sha>.
Why → A stash is a merge commit with two or three parents; it stays until pruned.
Interview tip → Do this fast, and avoid running git gc.
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