GitDropping & Clearing Stashes

Dropping & Clearing Stashes

Stashes accumulate. Old ones become noise, and a noisy stash stack is one where you can't remember which entry is which. This page covers the two ways to remove stashes — surgically with git stash drop, or all at once with git stash clear — plus the reflog tricks that can sometimes save you when you delete the wrong one.

Drop a single stash

Default drops stash@{0}

Bash
git stash drop
# Dropped refs/stash@{0} (a1b2c3d4e5f6...)

# Drop a specific one
git stash drop stash@{2}
# Dropped stash@{2} (1a2b3c4d5e6f...)

The output gives you the raw SHA of the dropped stash. Copy it — that's the only easy way to recover later if you regret it.

Indexes shift after a drop

Before and after dropping stash@{1}

Text
Before:                          After:
  stash@{0}: WIP feature/login      stash@{0}: WIP feature/login
  stash@{1}: WIP main hotfix        stash@{1}: WIP feature/cart
  stash@{2}: WIP feature/cart
Warning
Don't loop over stashes by index — drop one and every later index moves down. If you need to delete multiple, either drop from highest index to lowest, or just use `clear` and start over.
Clear ALL stashes

The nuclear option

Bash
git stash clear
# (no output on success — every stash is gone)
Warning
`git stash clear` removes every stash without confirmation and produces no output. Recovery is *only* possible via the reflog within Git's GC window (usually 30–90 days). Always `git stash list` and read carefully before clearing.
Recovery via reflog

Find a recently-dropped stash

Bash
# Stash deletions leave a trail in the stash reflog
git fsck --unreachable | grep commit
# unreachable commit a1b2c3d4e5f6...
# unreachable commit 9f8e7d6c5b4a...

# Inspect a candidate
git show a1b2c3d4e5f6

# If that's your stash, bring it back
git stash apply a1b2c3d4e5f6
# Or re-attach to the stash stack:
git update-ref --create-reflog refs/stash a1b2c3d4e5f6

Recovery works because Git doesn't immediately delete the underlying commit objects when you drop a stash — it just removes the reference. The objects survive until garbage collection runs. That's your safety net, but it's not eternal.

Why you'd intentionally clear
  • End-of-week tidy-up. You popped everything you needed; the rest is debris.

  • Switching focus to a new project. Old stashes have zero relevance to the new work.

  • Before a git gc --aggressive. Reduces the surface area Git has to traverse.

  • Confused stack state. Sometimes it's faster to clear than to disentangle.

Best practices
  • Drop after popping a conflict. pop keeps the stash if there's a conflict. Once you've resolved, run git stash drop.

  • Promote, don't hoard. If a stash has lived more than a couple of days, use git stash branch <name> to turn it into a real branch.

  • Use apply + drop instead of pop when nervous. Apply, verify everything is right, then drop.

  • Audit weekly. git stash list --date=relative once a week makes you the kind of engineer who never loses work.

A typical cleanup session

Friday tidy-up

Bash
git stash list --date=relative --pretty=format:"%gd  %cr  %s"
# stash@{0}  2 hours ago   WIP login validation
# stash@{1}  3 days ago    WIP cart refactor
# stash@{2}  2 weeks ago   debug spam from old bug

# Keep stash@{0}, promote stash@{1}, drop stash@{2}
git stash branch save/cart-refactor stash@{1}
# now stash@{1} is gone (branch creation drops it on success)
# the old stash@{2} just shifted to stash@{1}
git stash drop stash@{1}

git stash list
# stash@{0}: WIP login validation
What "Dropped" really means
Drop removes a ref, not a commit
`git stash drop` deletes the reference in the stash reflog. The underlying commit object lives on until garbage collection (default: 14 days for unreachable objects, sometimes longer). That's what gives you a recovery window — but treat it as belt-and-braces, not a real backup.
Real-world recipe: never lose work, even on clear

Backup before clearing

Bash
# Dump every stash to a branch first
i=0
while git rev-parse --verify "stash@{$i}" >/dev/null 2>&1; do
  git stash branch "backup/stash-$i" "stash@{$i}" || break
  i=$((i+1))
done

# Now safe to:
git stash clear
Tip
If you only ever remember one rule from this page: never run `git stash clear` without first running `git stash list`. Five seconds of reading saves you from a bad afternoon.