You need to stash only two files and keep the rest of your changes in place.
IntermediateScenarioUndoing Mistakes
Answer
Situation read → Default stash grabs everything.
What I'd do →
git stash push -m "wip: parser" -- src/parser.py src/lexer.py.- Or interactively:
git stash push -p. - To stash unstaged work but keep what is staged:
git stash push --keep-index.
Why → Pathspecs after -- limit the stash to those files (Git 2.13+).
Interview tip → Know --keep-index for testing exactly what you are about to commit.
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