Delete all Git stashes at once

Clear the stash list, preserve entries you may need, and understand the difference between removing a stash reference and immediately deleting its objects.

Best practices
Illustration of Git branches and version history

git stash clear removes every entry from the repository's stash list. Inspect the entries first; there is no ordinary undo command for clearing them.

git stash list
git stash clear

This does not apply the stashed changes or clear your current working-tree edits. Objects that become unreachable may remain temporarily, but recovery depends on whether Git has already pruned them. Do not rely on a fixed recovery window.

Remove one entry instead

git stash show --stat 'stash@{2}'
git stash drop 'stash@{2}'

Stash indexes change as entries are removed. Recheck the list rather than repeatedly deleting an old numeric position. Quote expressions such as stash@{2} so your shell passes them literally.

git stash pop is different: it applies an entry and drops it if the application succeeds. If conflicts prevent a clean application, Git keeps the stash entry so you can finish resolving it.

Preserve important work before clearing

Use descriptive messages for temporary work:

git stash push -m "Incomplete parser refactor"

For work you want to retain as ordinary history, start a branch from a stash:

git stash branch keep-for-later 'stash@{0}'
git status
# Review, stage, and commit the recovered work explicitly.

This creates a branch at the stash's original base and applies the saved work. On success it drops the referenced stash entry, but it does not commit those changes. Finish the commit or preserve them elsewhere before treating the new branch as a backup. Untracked files require appropriate stash options when initially saving them.

Attempt recovery after an accidental clear

Before running cleanup commands, inspect unreachable commits:

git fsck --unreachable

Use git show --no-patch --pretty=raw OBJECT_ID and inspect candidate trees and parents to identify the stash. Not every unreachable commit is a stash. If you find the correct object, restore a durable stash reference first:

git stash store -m "Recovered stash" OBJECT_ID
git stash show --stat 'stash@{0}'
git stash apply 'stash@{0}'

Apply into a suitable, preferably clean checkout and resolve conflicts if needed. --index can attempt to restore the original staged state as well. If the required objects have been deleted, these commands cannot reconstruct them.

Does clearing stashes reclaim disk space immediately?

No. Removing refs and reclaiming unreachable objects are separate operations, and objects may still be shared with other history. Clear entries because they are no longer needed, rather than assuming each entry corresponds to a fixed amount of recoverable disk space.

See git-stash and git-fsck.

Get a tailored plan

Contact us

Join the community

Scan with WeChat
to join the community

Try Guance

Start online and pay only for what you use.

Get started

Choose a Guance plan

Code hosting