How to Use git stash to Save Uncommitted Changes
git stash temporarily shelves uncommitted changes so you can switch branches cleanly, then restore them later with git stash pop.
Published September 20, 2026
git stash temporarily saves your uncommitted changes (both staged and unstaged) and reverts your working directory to match HEAD, so you can switch branches or pull without committing half-finished work.
git stash # save current changes
git checkout other-branch
# ... do work ...
git checkout original-branch
git stash pop # reapply the saved changesSteps
- Run git stash to save all uncommitted changes and clean your working directory
- Switch branches, pull updates, or do whatever required a clean tree
- Run git stash pop to reapply the most recent stash and remove it from the stash list, or git stash apply to reapply without removing it
How it works
Stashes are stored as special commits in a separate stack, viewable with git stash list. Each stash captures the full state of tracked, modified files (add -u to include untracked files too).
Things to watch for
- By default, git stash does not include untracked (new) files — use git stash -u to include them
- git stash pop can produce merge conflicts if the branch changed in ways that overlap with your stashed changes — resolve them like a normal merge conflict
FAQ
What's the difference between stash pop and stash apply?
pop applies the stash and then deletes it from the stash list; apply reapplies it but keeps it in the list, useful if you want to apply the same stash to multiple branches.