Resources / Guide
git stash: parking your work without committing
You're halfway through a change and something urgent comes up — a bug on main, a teammate's branch to check out. You can't commit half-finished work, and git won't switch branches cleanly with a messy tree. git stash pockets your changes, gives you a clean slate, and hands them back when you're ready.
The basic move
Stash everything you've changed but not committed:
git stash
Your working directory snaps back to the last commit — clean, as if you hadn't started. Your changes aren't gone; they're saved on a stack. Now you're free to switch branches, pull, fix the urgent thing, whatever you need.
When you're ready to pick your work back up:
git stash pop
That reapplies your changes and removes them from the stash. You're exactly where you left off, mid-change. That two-command rhythm — stash to park, pop to resume — covers the large majority of what you'll ever need stash for.
A worked example
The classic use is an urgent fix while you're mid-feature:
# mid-feature, files edited, not ready to commit
git stash # park it; working dir is clean now
git checkout main
git pull # get latest
# ... make the urgent fix, commit, push ...
git checkout feature/my-work # back to your branch
git stash pop # your half-done work is back
No throwaway "WIP" commit to clean up later, no losing your place. You detoured and came back.
Managing more than one
Stash is a stack, so you can have several. List them:
git stash list
stash@{0}: WIP on feature/my-work: 9f8e7d6 Add export button
stash@{1}: WIP on main: 4c5b6a7 Bump versions
A bare pop takes the most recent (stash@{0}). To apply a specific one, name it:
git stash apply stash@{1}
Note apply instead of pop: apply reapplies the changes but leaves the stash on the stack; pop reapplies and removes it. Use apply when you want the same stashed changes in more than one place, or when you're nervous and want a safety copy until you've confirmed it applied cleanly.
A tip that saves you later: give a stash a label so the list isn't a wall of "WIP on…":
git stash push -m "half-done export button"
A couple of things to know
Stashes are easy to forget. Because they're tucked away and out of sight, it's common to stash something, get pulled onto other work for a few days, and lose track of it. Run git stash list now and then so old stashes don't pile up. When you're sure you don't need one, drop it:
git stash drop stash@{0} # delete one
git stash clear # delete all (careful)
Popping can conflict. If the branch moved on underneath your stashed changes, pop can produce a merge conflict — the same kind you'd resolve in any merge. It's not a disaster; you fix the conflict markers as usual. (One nice property: a pop that hits a conflict doesn't drop the stash, so your saved work isn't lost while you sort it out.)
It's local only. A stash never gets pushed — it lives on your machine. It's a personal scratchpad for in-progress work, not a way to move changes between people. For that, you still want a branch and a commit.
When to use it
Stash shines for the quick detour: park a dirty working directory, do something else, come back. For anything you'll keep for more than a day, a real branch with a commit is usually the better home — it's visible, pushable, and won't get forgotten on a stack. But for "I need a clean tree for ten minutes," nothing beats git stash and git stash pop.
Want your team's git habits to just work?
Branching, stashing, clean PRs, a main that's always shippable — I help teams build the version-control muscle memory that keeps delivery smooth. If you'd like a hand, let's talk.