With git stash list, I see the list of stashes, Is it possible to drop a stash from somewhere in the middle of the stash list and not from the top.
Asked
Active
Viewed 3,946 times
7
-
@TimBiegeleisen: the question you marked this as a dupe of asks something very different. – John Zwinck Apr 11 '19 at 05:45
-
@JohnZwinck The accepted answer in that question says the same thing which your answer says. I would prefer that indexed duplicate link over this question. – Tim Biegeleisen Apr 11 '19 at 05:45
-
@TimBiegeleisen: There is no accepted answer in that question, and the most upvoted answer does not mention `drop` at all. – John Zwinck Apr 11 '19 at 05:46
-
I have added a more appropriate duplicate, though the OP should be able to figure out using either link. – Tim Biegeleisen Apr 11 '19 at 05:47
-
1@TimBiegeleisen: That ("pop specific stash in 1.8.3") is also not a duplicate question, because it is about a version incompatibility with the way stashes are named (and how shell escaping works) in an old version of Git. I think you are choosing dupes based on keywords in the answers, not based on what the questions are about. – John Zwinck Apr 11 '19 at 05:50
-
I agree with @JohnZwinck, this shouldn't be marked as duplicate, it is related but not duplicate. – vinodsaluja Apr 11 '19 at 05:59
-
I agree that the two previous dupes weren't ideal. I've just edited the list of dupes and added a better top duplicate, removed the "pop specific stash" duplicate, and left the "name and retrieve stashes" duplicate since knowing how to refer to stashes is important. This is still a duplicate (and covered in the documentation for `git stash`) and I'm not voting to re-open. – ChrisGPT was on strike Apr 11 '19 at 12:30
1 Answers
17
Sure, git stash --help
says:
git stash drop [-q|--quiet] [<stash>]
So you can specify a stash to drop (with the default being the most recent stash). For example:
git stash drop stash@{5}
stash@{5}
is the sequential label as shown in git stash list
. Note it is not stable over time--once you drop stash 5, stash 6 will then be called stash 5.

John Zwinck
- 239,568
- 38
- 324
- 436
-
5Depending on recent your `git` version is, you can use `git stash drop 5` as well. – Drew Daniels Aug 16 '22 at 20:11