How to name and retrieve a stash by name in git?

573    Asked by GloriaHoll in SQL Server , Asked on Jul 5, 2021
 I was always under the impression that you could give a stash a name by doing git stash save stashname, which you could, later on, apply by doing git stash apply stashname. But it seems that in this case, all that happens is that stashname will be used as the stash description.

Is there no way to actually name a stash? If not, what would you recommend to achieve equivalent functionality? Essentially I have a small stash that I would periodically like to apply, but don't want to always have to hunt in git stash list what its actual stash number is.

Answered by Edyth Ferrill

As per git versions 2.15, this command git stash with name save is deleted and instead of that now we havegit stash push -m "message"

The message is the note of push

And if you need to retrieve you can use git stash list this will give you a list as output

For example:

stash@{0}: On develop: perf-spike
stash@{1}: On develop: node v10

Then for retrieving you just need to do an apply with stash@{index}

For example:

    git stash apply stash@{1}


Your Answer

Interviews

Parent Categories