snippetbashgitTippending
Git Stash Advanced Usage Patterns
Viewed 0 times
git stashpartial stashstash pushstash branchworkflow
Problem
Basic git stash usage (stash/pop) loses track of what was stashed and doesn't handle partial stashing or untracked files.
Solution
Advanced stash patterns:
# Stash with a descriptive message
git stash push -m 'WIP: auth refactor - halfway through token validation'
# Stash specific files only
git stash push -m 'just the config' -- config.yaml src/config.ts
# Stash including untracked files
git stash push -u -m 'include new files'
# Stash interactively (select hunks)
git stash push -p -m 'partial changes'
# List stashes with details
git stash list
# stash@{0}: On main: WIP: auth refactor
# stash@{1}: On feature: just the config
# Show what's in a stash
git stash show -p stash@{1}
# Apply without removing from stash list
git stash apply stash@{1}
# Create a branch from a stash
git stash branch new-feature stash@{0}
# Drop a specific stash
git stash drop stash@{2}
# Apply and drop in one step
git stash pop stash@{0}Why
Named stashes prevent the 'what was in this stash?' problem. Partial stashing lets you commit clean chunks while keeping WIP changes aside.
Gotchas
- Stash indices shift when you drop entries
- git stash pop with conflicts leaves the stash in the list (doesn't auto-drop)
Context
Managing work-in-progress changes across branches
Revisions (0)
No revisions yet.