git stash lets you set aside uncommitted work-in-progress changes on demand, giving you a clean working directory to handle an urgent task, with the ability to restore your exact state afterward.
While halfway through a refactor, an urgent production bug needs fixing; running git stash clears the working directory, the bug gets fixed and committed on its own branch, and git stash pop afterward brings the refactor's uncommitted changes right back.
git stash
# fix the urgent bug, commit, push
git stash popA concise interview answer is
I'd run git stash to set aside my uncommitted changes and get a clean working directory, handle the urgent bug fix, and then run git stash pop to bring my original work back exactly as it was. It avoids committing half-finished code just to switch tasks.
Last updated: 11 November 2026
Previous question: Your feature branch is several commits behind main. How do you use git rebase to update it?
Next question: A recent deployment caused a serious issue. How do you undo the last commit?