How to remove range of git stash?

前端 未结 4 1744
没有蜡笔的小新
没有蜡笔的小新 2021-01-04 02:07

I want to remove all stash\'es, except most recent, from git stash list.

E.g. I want to remove stash 1 to 3 in a single git command:

4条回答
  •  死守一世寂寞
    2021-01-04 02:44

    I would add something extra to below provided answer If you want to log the index of dropped stashes as well You can use descending order and $nas shown below

    for n in {3..1}; do git stash drop stash@{$n}; done;
    

    The output will be something like..

    Dropped stash@{3} (beeaf3629b53d612b1a3fabb7b0c4f77d17e9b71)
    Dropped stash@{2} (5a687ca9a93b3190882a9af2c15134e75f063f41)
    Dropped stash@{1} (e33dfc42d03166def5dbb60baa975efb21b27f07)
    

提交回复
热议问题