How can I delete some of my Git stashes at once? I tried in sourceTree, but it seems I can only delete one stash at a time. Can I delete several of them at the same time? Is there a command to do this in git bash? I don't want to delete all of them.
With Bash Brace Expansion, we can create a long list of stashes quickly, e.g., stash@{8} stash@{7} stash@{6} stash@{5} stash@{3} stash@{1}
can be made with echo stash@\{{8..5}\} stash@\{{3,1}\}
Putting together with xargs
, or a for
loop, we get:
echo stash@\{{8..5}\} stash@\{{3,1}\} | xargs -rn1 git stash drop
Note: the list must be reversed.