Stash Work-in-Progress and Restore It Later
Save WIP changes to the stash, inspect the stack, and reapply when ready.
When to use
You have uncommitted work but need to check out another branch, pull in upstream changes, or test a clean workspace without discarding local edits.
Pre-flight checklist
- Confirm which files are modified so you know what will be stashed.
- Decide whether to include untracked files; add
-uif you want them saved too.
Steps
-
Review the working tree and decide whether new files should be included.
git status git diff --stat -
Store the changes with a descriptive message so you can recognize the stash later. Include
-uto capture untracked files.git stash push -u -m "wip: update onboarding copy" -
List the stash stack to confirm the entry exists and note its index.
git stash list -
Reapply the stash when you are ready: use
applyto keep it on the stack orpopto remove it after a successful merge.# Reapply but keep for later git stash apply stash@{0} # Reapply and drop from the stack git stash pop stash@{0} -
Clean up stale stashes once they are no longer useful.
git stash drop stash@{0} # Remove everything if the stack is cluttered git stash clear
Verification
git statusshows a clean working tree after stashing and restored changes after applying.git stash listreflects the expected entries (or an empty stack after cleanup).
Follow-up
- Commit the restored work once it is ready so you do not rely on the stash long-term.
- If conflicts appear during
apply, resolve them and rungit stash dropmanually.