When working with Git version control, you may often need to save your unfinished changes without committing them. This is where Git Stash comes in. It allows you to temporarily save uncommitted changes, switch branches to fix urgent issues, and later restore your work.
What is Git Stash?
Git Stash is a powerful Git command that saves your working directory changes (modified and staged files) into a temporary stack. This lets you switch branches or fix bugs without losing your ongoing work.
Real-World Example of Git Stash
Suppose you are developing a new feature in a separate branch, but suddenly you need to hotfix a bug in the production (live environment). Since your feature is not finished, you cannot commit it. In this case, you use Git Stash to save your unfinished code, switch to the main branch, fix the bug, deploy the hotfix, and later apply your stashed changes back to continue working.
Common Git Stash Commands
Save Changes to Stash
git stash
or with a message:
git stash save "WIP: feature progress"
View Stash List
git stash list
Apply Last Stash (keep in stash)
git stash apply
Apply and Remove Last Stash
git stash pop
Apply Specific Stash
git stash apply stash@{2}
Drop/Delete a Stash
git stash drop stash@{0}
Clear All Stashes
git stash clear
When to Use Git Stash?
- Hotfix production bugs while coding a new feature
- Switching branches without committing unfinished work
- Testing experimental code safely
- Keeping your Git workflow clean and efficient
Final Thoughts
Using Git Stash in real-world scenarios—like pausing a feature branch to hotfix production—makes your development workflow more flexible and efficient. Mastering commands like git stash save, git stash apply, git stash pop, and git stash drop will help you handle urgent changes without losing progress.

