How do I name and retrieve a Git stash by name?

To save a stash with a message:

git stash push -m "my_stash_name"

To list stashes:

git stash list

All the stashes are stored in a stack.


To apply and remove the nth stash:

git stash pop stash@{n}

To apply and remove a stash by name:

git stash pop stash^{/my_stash_name}

To apply the nth stash:

git stash apply stash@{n}

To apply a stash by name:

git stash apply stash^{/my_stash_name}

Leave a Comment