Never Lose Track of Stashed Changes
Labeled stashes turn a pile of mystery changes into an organized queue you can navigate with confidence.
What
git stash push -m "message" (or the older git stash save "message") lets you label your stashes so you know what each one contains. Without a message, stashes are identified only by cryptic auto-generated names like WIP on main, making it nearly impossible to tell them apart.
Why It Matters
Developers often accumulate multiple stashes while context-switching between tasks. Without descriptive messages, you end up playing guesswork with git stash list, popping random stashes, or worse β applying the wrong stash to the wrong branch. A clear label saves time and prevents mistakes.
Example
# Stash with a descriptive message
git stash push -m "WIP: login form validation"
# Stash only specific files with a message
git stash push -m "WIP: navbar styling" -- src/components/Navbar.tsx
# List all stashes β messages make this useful
git stash list
# stash@{0}: On main: WIP: login form validation
# stash@{1}: On main: WIP: navbar styling
# Apply a specific stash by index
git stash apply stash@{1}
# Pop (apply and remove) a specific stash
git stash pop stash@{0}Common Mistake
Using plain git stash without a message, then forgetting what each stash contains. After a few stashes pile up, you can't tell which is which and may apply the wrong one or drop stashes you still need.
Quick Fix
Always use git stash push -m "description" instead of plain git stash. If you already have unlabeled stashes, use git stash show stash@{N} to peek at the contents before applying.
Key Takeaways
- 1git stash push -m "message" labels your stash
- 2git stash list shows all stashes with their labels
- 3git stash show stash@{N} previews stash contents
- 4git stash apply stash@{N} applies without removing
- 5Always label stashes β your future self will thank you
Was this tip helpful?
Help us improve the DevOpsPath daily collection