Interview Prep/Git & GitHub/Undoing Mistakes

You stashed changes but your new, untracked files stayed behind.

BeginnerScenarioUndoing Mistakes
Answer

Situation read → Plain git stash saves only tracked changes.

What I'd do →

  1. git stash push -u -m "wip: payment form" includes untracked files.
  2. Add -a to include ignored files too (rarely needed).
  3. List with git stash list, restore with git stash pop.

Why → Untracked files are not in the index or HEAD, so they must be requested explicitly.

Interview tip → Always name stashes with -m. stash@{3} means nothing a week later.

All Git & GitHub questions Roadmap: Git & GitHub

More on Undoing Mistakes