Skip to content

Stash

Back to Git


📦 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

Stash

By default, it saves with a generic message. You can also run git stash save:

git stash save

Stash Save

2. Stash with Message

To stash with a descriptive message (recommended):

git stash save "message"

Stash Save Message

3. List Stash

To view stored stashes:

git stash list

Stash List

4. Apply Stash

To apply the most recent stash (keeps it in the list):

git stash apply

Stash Apply

To apply a specific stash:

git stash apply stash@{index_no}

Stash Apply Index

5. Stash Untracked Files

By default, git stash only stores tracked files. To stash untracked (new) files as well:

git stash -u

Stash Untracked

6. Pop Stash

To apply the most recent stash and remove it from the list immediately:

git stash pop

Stash Pop

7. View Stash Changes

To see what files changed in a stash:

git stash show stash@{index_no}

Stash Show

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

Stash Branch

Or from a specific stash:

git stash branch new_branch_name stash@{index_no}

Stash Branch Index

9. Drop Stash

To remove the most recent stash:

git stash drop

Stash Drop

To remove a specific stash:

git stash drop stash@{index_no}

Stash Drop Index

10. Clear All Stashes

To remove all stashes from the list:

git stash clear

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