In short
You're halfway through a feature and someone says 'urgent bug on main!'. Your work isn't ready to commit. Stash tucks it away safely so you can switch.
`git stash` temporarily shelves uncommitted changes so you can switch branches cleanly, then reapply them later with `git stash pop`. Stashes are useful for short-lived context switches, but meaningful work is generally safer as a branch or commit so it remains visible and shareable.

Think of it like this
Putting your notes in your bag
You're writing notes when the professor says 'clear your desk, surprise test'. You don't throw the notes away. You slide them into your bag, take the test, then take them out again. That's git stash.
Watch it happen
The stash shelf
Top of the stack is coloured
1/4git stash push -u -m "search bar WIP" shelves your unfinished work. Your folder is clean again.
The big ideas
What you need to know
Saves unfinished work
git stash takes your uncommitted changes and puts them on a shelf. Your folder goes back to clean.
pop brings it back
git stash pop re-applies the latest stash and removes it from the shelf.
It's a stack
You can stash many times. git stash list shows them all, newest on top.
New files need -u
By default, brand new untracked files aren't stashed. Add -u to include them.
How it works
Handling an urgent interruption
- 1
Stash your work
git stash push -u -m with a short note about what it is.
- 2
Switch and fix
Go to main, fix the bug, commit and push.
- 3
Come back
Switch to your feature branch again.
- 4
Pop the stash
git stash pop and continue exactly where you left off.
See it in code
Walk through the code
1git stash push -u -m "half-done search bar"2git switch main3# ...fix the bug, commit, push...4 5git switch feature/search6git stash list7# stash@{0}: On feature/search: half-done search bar8 9git stash pop # apply and remove from the list10# git stash apply # apply but keep a copy in the list1/4Shelve all changes, including new files (-u), with a note so you recognise it later.
Always add a message with -m. A week later, 'stash@{3}: WIP on main' tells you nothing.
Save yourself the pain
Common mistakes
Oops
Stashing and forgetting, until you have ten mystery stashes.
Do this instead
Treat stash as short-term. Pop it the same day, or commit the work on a branch instead.
Oops
Stashing without -u and losing track of a new file.
Do this instead
Use git stash push -u so new, untracked files go into the stash too.
Your mission
Survive an interruption
Quick check
You run git stash, but your new file notes.txt is still sitting in the folder. Why?
Go deeper
- 1Make some uncommitted changes, stash them, switch branches, then pop them back. Validate your understanding by applying it in a small practical example.
- 2Learn `git stash list` and `git stash apply <n>` for managing multiple stashes. Focus on understanding the underlying reason it works, not only memorizing the definition.
- 3Practice `git stash push -m 'message'` to label stashes for clarity.
More topics at this stop
Stuck on this topic? Ask an Insider
Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.