There's more...

For stashes applied with git stash apply, the stash needs to be deleted with git stash drop:

$ git stash drop 'stash@{1}'
Dropped stash@{1} (e634b347d04c13fc0a0d155a3c5893a1d3841fcd)
$ git stash list
stash@{0}: On master: Made another change to bar
stash@{1}: WIP on master: 1676cdb Update foo

Keeping the stashes in the stash list by using stash apply and explicitly deleting them with git stash drop has some advantages over just using stash pop. When using the pop option, the stashes in the list are automatically deleted if they can be successfully applied. But if it fails and triggers the conflict resolution mode, the stash applied is not dropped from the list and continues to exist on the stash stack. This might later lead ...

Get Git Version Control Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.