git stash pop brings the changes back later.What stashing is for
You're in the middle of editing, then something urgent comes up — you need to switch branches,
or pull the latest code, but your changes aren't ready to commit. git stash takes
your uncommitted changes, tucks them away, and gives you a clean working tree. Later you pop
them back exactly where you left off.
Mental model: stash is a clipboard for changes. Cut now, paste back soon. It's meant to be temporary — not a place to store work for days.
Stash your changes
Running git stash shelves all your tracked, modified files. Add a message so you
remember what it was — handy if you end up with more than one stash.
Shelve your work
$ git stash # quick shelve
$ git stash push -m "half-done navbar" # with a label - Source Control panel → '…' menu → Stash
- Type an optional message when prompted
By default stash ignores brand-new (untracked) files — see the -u tip below if you need those too.
See and restore your stashes
git stash list shows what you've shelved. Bring the newest one back with
git stash pop — it re-applies the changes and removes it from the list.
List and bring back
$ git stash list
$ git stash pop # apply the latest stash and remove it
$ git stash apply # apply it but KEEP it in the list - Source Control → '…' → Stash → Pop Stash… (or Apply Stash)
- Pick which stash to restore from the list
pop = apply + delete. apply = apply but keep it, in case you want it again on another branch.
Manage multiple stashes
Stashes form a stack — the newest is stash@0. You can pop a specific one, throw
one away, or clear them all.
Pick, drop or clear
$ git stash pop stash@{1} # restore a specific stash
$ git stash drop stash@{0} # delete one without applying
$ git stash clear # delete ALL stashes - The Stash menu lists each stash with its message so you can choose
- Drop Stash… removes one you no longer need
Include untracked files: brand-new files aren't stashed by default. Add -u to include them: git stash -u (or git stash push -u -m "msg").
When pop hits a conflict
If the code changed while your work was shelved, git stash pop can raise a
conflict — the same situation as a merge conflict, and the same fix. One quirk to know:
a conflicted pop does not delete the stash, so once you've resolved it you drop
the stash yourself.
Resolve a conflicted pop
$ git stash pop
$ # CONFLICT → fix the file, then: git add .
$ git stash drop # a conflicted pop keeps the stash; drop it once resolved - Conflicted files appear under Merge Changes — resolve them like any merge (see Fix Merge Conflicts)
- Then '…' → Stash → Drop Stash… to remove the now-applied stash
Stash or a quick commit?
Stash is great for a short detour — pull, peek at another branch, then come straight
back. If the work will sit for a while, a small "WIP" commit on a branch is safer and clearer:
it's backed up, shows in your history, and won't get lost in a forgotten stash. You can always
tidy it later with git commit --amend or git reset (see the
Undo Commits chapter).
Up next: the GitHub side — starting with the one-time sign-in that makes push and pull work, in VS Code and the terminal.