All chapters in this track
- 011. The Mental Model
- 022. Essential Setup
- 033. Core Daily Workflow
- 044. Branching
- 055. Merging & Conflict Resolution
- 066. Rebasing
- 077. Remote Repositories
- 088. Stashing
- 099. Undoing Things
- 1010. Tagging & Versioning
- 1111. Cherry-Pick
- 1212. Git Bisect & Blame
- 1313. Git Hooks
- 1414. Submodules
- 1515. Team Workflows
- 1616. Power Commands & Aliases
- 1717. Reflog: The Safety Net
- 1818. Practice Tasks
- 19Quick Reference Cheatsheet
Chapter 8 of 19
8. Stashing
Stash lets you temporarily shelve changes without committing.
# Save stash
git stash # stash tracked changes
git stash push -m "login WIP" # named stash
git stash -u # include untracked files
git stash -a # include ignored files too
# List stashes
git stash list
# stash@{0}: On main: login WIP
# stash@{1}: WIP on feature/x: a3b2c1 ...
# Apply
git stash pop # apply top stash + remove it
git stash apply stash@{1} # apply specific stash, keep it
git stash drop stash@{0} # delete a stash
git stash clear # delete ALL stashes
# Inspect
git stash show -p stash@{0} # diff of a stash
# Create branch from stash
git stash branch feature/rescued stash@{0}
When to stash:
- You need to switch branches but aren't ready to commit
- A teammate asks you to review their branch immediately
- You want to test clean state (stash your changes, run tests)