Temporarily save and restore uncommitted work.
low risk
git stash saves your working directory changes and index to a stack, letting you switch contexts cleanly and restore later. Supports multiple stashes, partial stashing with -p, and stashing untracked files with -u.
| Flag | Meaning |
|---|---|
push -m | Stash with a descriptive message |
pop | Apply most recent stash and remove it |
apply | Apply stash without removing it |
list | Show all stashes |
drop | Delete a specific stash |
-u | Include untracked files |
-p | Interactively choose hunks to stash |
git stash push -m 'WIP: refactor auth module'Stash with descriptive message · explain & risk-check →git stash listView all stashes · explain & risk-check →git stash popRestore most recent stash · explain & risk-check →git stash show -p stash@{1}View diff of second stash · explain & risk-check →Use `git stash push -u -m 'description'` to include untracked files — otherwise new files you've created stay in the working tree and may contaminate the branch you switch to.
Reference text is hand-written and may be incomplete — check man git for your version. Test destructive commands on a non-production system first.