Git Stash: Honestly, a Total Life Saver
Anowar Hossen Farvez
Software Engineer
Ever been in the middle of a feature when you suddenly need to switch branches?
git stash is your superhero — it temporarily stores your unfinished changes
so you can work on something else without losing anything.
The Problem
You're deep into coding a new feature when suddenly:
- A critical bug needs immediate attention
- Your teammate needs help on their branch
- You need to pull the latest changes from main
But your current work isn't ready to commit. What do you do?
The Solution: git stash
Git stash saves your work-in-progress and gives you a clean working directory — without making a messy commit.
Save Your Work
git stash
This saves all your uncommitted changes and cleans your working directory.
Get Your Work Back
git stash pop
This retrieves your saved changes and applies them back. It also removes the stash from the list.
View All Your Stashes
git stash list
See all your saved stashes with their labels.
Apply a Specific Stash
git stash apply stash@{1}
Apply a specific stash without removing it from the list.
Clean Up Old Stashes
git stash drop stash@{0}
Remove a stash you no longer need.
Why Git Stash is a Life Saver
A small Git feature that saves you hours of stress and keeps your commits clean.
- Clean commits: No more "WIP" or "temp" commits cluttering your history
- Easy context switching: Jump between tasks without losing work
- Branch flexibility: Switch branches freely, even with uncommitted changes
- Reduced stress: Unexpected interruptions? No problem!
Pro Tips
- Use
git stash save "description"to add a message to your stash - Use
git stash -uto also stash untracked files - Use
git stash branch new-branchto create a branch from a stash
Conclusion
git stash is one of those small features that makes a huge difference in your daily workflow.
Next time you need to switch contexts unexpectedly, you'll be glad you know it!