Can we run multiple GIT STASH ?
Yes. You can have multiple stashes. Every time you run git stash, Git creates a new stash entry and stores it in a stack (Last-In, First-Out), as long as you have changes to stash.
Example
Step 1: Modify 5 files
app.js
login.js
user.js
config.js
api.js
Run:
git stash
Now:
Working tree is clean.
Git creates:
stash@{0} ← contains 5 files
Step 2: Modify 2 more files
payment.js
checkout.js
Run:
git stash
Now Git creates another stash.
stash@{0} ← payment.js, checkout.js
stash@{1} ← app.js, login.js, user.js, config.js, api.js
Notice that the newest stash is always stash@{0}.
View all stashes
git stash list
Example output:
stash@{0}: WIP on feature/payment
stash@{1}: WIP on feature/login
Restore the latest stash
git stash pop
This restores:
payment.js
checkout.js
Now the stash list becomes:
stash@{0} ← app.js, login.js, user.js, config.js, api.js
The older stash moves up because the latest one was removed.
Restore a specific stash
Suppose you want the older one first:
git stash apply stash@{1}
or
git stash pop stash@{1}
applyrestores it without deleting it.poprestores it and removes it from the stash list.
Think of it as a stack of books
Imagine each git stash puts your current work into a new box and stacks it on top.
Top
┌─────────────────────────────┐
│ stash@{0} → 2 files │
├─────────────────────────────┤
│ stash@{1} → 5 files │
├─────────────────────────────┤
│ stash@{2} → Older stash │
└─────────────────────────────┘
Bottom
When you run:
git stash pop
Git takes the top box (stash@{0}), restores those changes, and removes that box from the stack.
Key points
✅ You can create multiple stashes.
✅ Each
git stashcreates a new, separate snapshot of your current changes.✅
git stash listshows all stashes.✅
git stash poprestores the latest stash by default.✅
git stash applyrestores a stash but leaves it in the stash list.✅ You can restore a specific stash using its identifier, such as
stash@{1}.
This makes git stash very useful when you're interrupted multiple times and need to save different sets of unfinished work independently.
.png)