git stash apply syntax

February 28th, 2008

It took me a few tries to figure out how ‘git stash apply’ can apply a specific stash. The trick is you have to use the stash{@X} as listed in git stash list, not the string you gave it.

So if git stash list has

bcooke@cc $ git stash list
stash@{0}: On local-trunk: names changed to protect w/ correct files
stash@{1}: On local-trunk: the innocent
stash@{2}: On local-trunk: background that thing

To apply the stash named “background that thing” I just have to run

git stash apply stash@{2}

and all is well.