When I have more stashes than one, sometimes I need to drop one or two before the last one:
> git stash
stash@{0}: WIP on 0.9.1: e59f763 UPDATE deploy script UPDATE requirements
stash@{1}: WIP on dev: c9f86fb ADD index view ADD return view ADD welcome
In this case I want to drop @{0}. If I git stash pop I got into merge conflicts that I have to solve manually, maybe not only once, to get rid of the stashed commit.
Usually, I create another branch:
git checkout -b temp
git stash pop
# solve merge-conflicts
git checkout branch_for_stash@{1}
git stash pop
Is there any (git) command to remove the last, or even any stashed commit?
It appears the the question was already answered in the comments. For future reference, here's the corresponding documentation for git stash drop:
Remove a single stash entry from the list of stash entries. When no <stash> is given, it removes the latest one. i.e. stash@{0}, otherwise <stash> must be a valid stash log reference of the form stash@{<revision>}.
So to drop just the stash entry stash@{1}, the command would look like:
$ git stash drop stash@{1}
Note that the number in the reference is a count from the top of the list, so dropping stash@{1} twice in a row will remove stash@{1} and then what previously was stash@{2}.
This works equally for the git stash apply and git stash pop commands, i.e.:
$ git stash apply stash@{1}
$ git stash pop stash@{1}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With