Stash
📦 Git Stash¶
Stashing allows you to temporarily save changes that are not ready to be committed, so you can switch branches or work on something else.
1. Stash Changes¶
To stash your modified tracked files:
git stash
By default, it saves with a generic message. You can also run git stash save:
git stash save
2. Stash with Message¶
To stash with a descriptive message (recommended):
git stash save "message"
3. List Stash¶
To view stored stashes:
git stash list
4. Apply Stash¶
To apply the most recent stash (keeps it in the list):
git stash apply
To apply a specific stash:
git stash apply stash@{index_no}
5. Stash Untracked Files¶
By default, git stash only stores tracked files. To stash untracked (new) files as well:
git stash -u
6. Pop Stash¶
To apply the most recent stash and remove it from the list immediately:
git stash pop
7. View Stash Changes¶
To see what files changed in a stash:
git stash show stash@{index_no}
8. Create Branch from Stash¶
To take stash changes and create a new branch immediately (useful if apply causes conflicts):
git stash branch new_branch_name
Or from a specific stash:
git stash branch new_branch_name stash@{index_no}
9. Drop Stash¶
To remove the most recent stash:
git stash drop
To remove a specific stash:
git stash drop stash@{index_no}
10. Clear All Stashes¶
To remove all stashes from the list:
git stash clear
🧠 Quick Quiz — Stashing¶
What does git stash pop do?
📝 Want More Practice?¶
👉 Start Git Beginner Quiz (20 Questions)
📬 DevopsPilot Weekly — Learn DevOps, Cloud & Gen AI the simple way.
👉 Subscribe here