What does git stash do?
Options
- Deletes uncommitted changes forever, with no way back
- Saves uncommitted changes on a stack;
stash poprestores (Correct option) - Pushes the uncommitted changes to the remote branch
- Creates a tag on the current commit of the branch
Answer
Temporarily saves your uncommitted changes on a stack and cleans the working directory, so you can switch tasks; git stash pop brings them back
Why
You are halfway through a change and need to switch branch to fix something urgent. You do not want to commit unfinished work.
git stash stores your changes in a temporary shelf and gives you a clean directory. Later git stash pop reapplies them (and removes them from the shelf); git stash list shows the stack.
Remember
stash = shelf for unfinished work.