bashbeginner
Git Stash — Named, Partial, and Pop Strategies
Advanced stash techniques: named stashes, partial stash, stash apply vs pop, and branch from stash.
bashPress ⌘/Ctrl + Shift + C to copy
# Stash with a descriptive message
git stash push -m "WIP: refactoring auth module"
# Stash only specific files
git stash push -m "partial: only api changes" -- src/api/ src/routes/
# Stash including untracked files
git stash push --include-untracked -m "with new files"
# Stash only staged changes (keep unstaged)
git stash push --staged -m "staged only"
# Interactive stash (choose hunks)
git stash push -p -m "selected hunks"
# List all stashes
git stash list
# stash@{0}: On main: WIP: refactoring auth module
# stash@{1}: On feature: partial: only api changes
# Apply without removing from stash list
git stash apply stash@{0}
# Apply AND remove from stash list
git stash pop stash@{0}
# Create a branch from a stash
git stash branch new-feature stash@{1}
# Show diff of a stash
git stash show -p stash@{0}
# Drop a specific stash
git stash drop stash@{1}
# Clear all stashes (careful!)
git stash clearUse Cases
- Saving work in progress before switching branches
- Stashing only selected changes for review
- Creating branches from old stashed work
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashbeginner
Git Stash Usage Examples
Save, list, apply, and manage uncommitted changes with git stash for quick context switching.
Best for: Switching branches with uncommitted work
#git#stash
bashintermediate
Git Rebase Workflow Example
Step-by-step git rebase workflow to keep feature branches up to date with main branch cleanly.
Best for: Keeping feature branches linear with main
#git#rebase
bashadvanced
Git Worktree for Multiple Branches
Work on multiple branches simultaneously using git worktree without stashing or switching.
Best for: Reviewing PRs while working on a feature
#git#worktree
bashbeginner
Git Aliases for Productivity
Essential git aliases and config settings to speed up daily git workflow and reduce typing.
Best for: Speeding up daily git workflow
#git#aliases