git stash drop removes one stash entry from the stack without applying it.
Drop is how you discard a stash you no longer need, or clean up after a conflicted pop. It is destructive, but a dropped stash is briefly recoverable through the stash reflog.
What it does
git stash drop deletes the specified stash entry (the latest by default) from the stack. git stash clear deletes every entry at once.
Common usage
Terminal
git stash drop # drop stash@{0}
git stash drop stash@{2}
git stash clear # remove all entries
# recover a just-dropped stash:
git stash apply <sha-from-stash-reflog>
Options
Item
What it does
[<stash>]
Drop a specific entry (default: stash@{0})
clear
Remove all stash entries
-q / --quiet
Suppress output
Common errors in CI
fatal: <stash> is not a valid reference - the index is out of range or the stack is empty. List first with git stash list. A dropped or cleared stash is not immediately gone; its commit lingers in the stash reflog until gc, so recovery is possible with git fsck --unreachable or the reflog SHA.
Using this in CI
CI checkouts are shallow and detached by default, which changes the answer this command gives you. Commands that read history, branch names, or tags need the checkout configured for it.
.github/workflows/ci.yml
- uses:actions/checkout@v4with:fetch-depth:0 # history, tags, and git describe all need this- run:|git rev-parse --is-shallow-repository # expect falsegit rev-parse --abbrev-ref HEAD # prints HEAD when detached
Frequently asked questions
git stash drop: Usage, Options & Common CI Errors?
Drop is how you discard a stash you no longer need, or clean up after a conflicted pop. It is destructive, but a dropped stash is briefly recoverable through the stash reflog.
What it does?
git stash drop deletes the specified stash entry (the latest by default) from the stack. git stash clear deletes every entry at once.
Common errors in CI?
fatal: <stash> is not a valid reference - the index is out of range or the stack is empty. List first with git stash list. A dropped or cleared stash is not immediately gone; its commit lingers in the stash reflog until gc, so recovery is possible with git fsck --unreachable or the reflog SHA.