Git Stashing Cheat Sheet

Master git stash — save, list, apply, pop, drop, branch from stash, partial stashing, and cleaning up your stash stack.

Last Updated: May 1, 2025

Basic Stash Commands

git stash
Save all tracked changes to a stash stack
git stash push -m description
Stash with a descriptive message
git stash list
List all stashed changes
git stash show -p stash@{0}
Show full diff of a specific stash
git stash pop
Apply the most recent stash AND remove it
git stash apply
Apply the most recent stash WITHOUT removing it
git stash drop stash@{0}
Delete a specific stash entry
git stash clear
Remove ALL stashes (cannot be undone)

Partial & Advanced Stashing

git stash push file1 file2
Stash only specific files
git stash push -p
Interactively choose hunks to stash (very useful)
git stash push --keep-index
Stash working changes but keep staged changes
git stash push --include-untracked
Stash untracked files too
git stash push --all
Stash ALL files including ignored ones
git stash branch new-branch stash@{0}
Create a branch from a stash entry
git stash show --stat
Show summary of files changed in stash
git stash pop --index
Pop stash and re-stage files that were staged

Stash Stack Management

ItemDescription
stash@{0}Most recent stash (top of stack)
stash@{1}Second most recent stash
git stash list --statShow file summaries for all stashes
git stash drop stash@{0}Remove the top stash after applying
git stash pop stash@{1}Pop a specific stash (not just the top)
git stash store -m msg shaManually insert a commit into stash stack
git stash show stash@{1}Inspect an older stash without applying
stash reorderingStashes are a stack — you cannot reorder directly

Common Stash Workflows

ItemDescription
Quick Context Switchstash → switch branches → work → switch back → stash pop
Pull with Local Changesstash → pull → stash pop (cleaner than merge)
Experiment Safelystash working state → try an idea → pop to restore if needed
Patch Sharingstash → git stash show -p > fix.patch (share as patch file)
Pre-Rebase Safetystash before rebase — easy rollback if rebase goes wrong
Code Review Prepstash unrelated changes so reviewers see only relevant diff
Testing Clean Statestash → run tests on clean HEAD → pop to resume work
Partial Commitstash some changes → commit the rest → pop to continue
Pro Tip: Name your stashes with `git stash push -m 'description'` — you'll thank yourself when you have 10+ entries.