Interview Prep/Git & GitHub/Undoing Mistakes

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 →

  1. git stash push -m "wip: parser" -- src/parser.py src/lexer.py.
  2. Or interactively: git stash push -p.
  3. 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.

All Git & GitHub questions Roadmap: Git & GitHub

More on Undoing Mistakes