bashbeginner
Git Stash Usage Examples
Save, list, apply, and manage uncommitted changes with git stash for quick context switching.
bashPress ⌘/Ctrl + Shift + C to copy
# Stash current changes (tracked files)
git stash
# Stash with a descriptive message
git stash push -m "WIP: authentication flow"
# Stash including untracked files
git stash push -u -m "WIP: includes new files"
# Stash only specific files
git stash push -m "partial stash" src/auth.ts src/utils.ts
# List all stashes
git stash list
# Apply most recent stash (keep in stash list)
git stash apply
# Apply and remove from stash list
git stash pop
# Apply a specific stash
git stash apply stash@{2}
# View stash contents
git stash show -p stash@{0}
# Create a branch from a stash
git stash branch new-branch stash@{0}
# Drop a specific stash
git stash drop stash@{1}
# Clear all stashes
git stash clearUse Cases
- Switching branches with uncommitted work
- Temporarily shelving changes for code review
- Saving partial work before pulling updates
Tags
Related Snippets
Similar patterns you can reuse in the same workflow.
bashbeginner
Git Stash — Named, Partial, and Pop Strategies
Advanced stash techniques: named stashes, partial stash, stash apply vs pop, and branch from stash.
Best for: Saving work in progress before switching branches
#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
bashintermediate
Git Patch Create and Apply Workflow
Generate and apply git patches to share changes via email or transfer between repositories.
Best for: Sharing changes without push access
#git#patch
bashadvanced
Git Rebase Strategies Guide
Advanced rebase strategies for cleaning history including onto, autosquash, and conflict resolution.
Best for: Cleaning commit history before merging
#git#rebase