Skip to main content

Choosing a stash from the list

First posted in Development and Git; updated 9th February 2021

Git stash is easy to get started with but what if you stash more than once? You might want to have a look at your stashes:

git stash list

This brings up a list of all of the stashes in your current repository (which is much easier understand if you’ve named your stashes); to choose a particular stash, all you have to do is find the index of the stash:

  1. View your list of stashes
  2. Copy the stash index number (which looks something like stash@{2})
  3. Close the list with (Control) + z

Now we just add the stash’s index to our pop command:

git stash pop stash@{2}

If you know without having to look where the stash will be in the list, you might not want to view the list before applying the stash, but bear in mind:

  • Stashes are numbered in reverse order, so the most recent always has the lowest index number
  • The index numbers change with each new stash that’s added, effectively getting pushed back in the queue
  • Stashes are ‘zero indexed’, so the most recent stash would be stash@{0}, the next most recent stash@{1}, and so on

So, for example, if you’ve stashed four times and you want the second stash you made, you’d run git stash pop stash@{2}.

If you stash a fifth time before grabbing that second stash, you’d run git stash pop stash@{3} as there are now 5 items: 0, 1, 2, 3, and 4.

Accessibility in your inbox

I send an accessibility-centric newsletter on the last day of every month, containing:

  • A roundup of the articles I’ve posted
  • A hot pick from my archives
  • Some interesting posts from around the web

I don’t collect any data on when, where or if people open the emails I send them. Your email will only be used to send you newsletters and will never be passed on. You can unsubscribe at any time.

More posts

Here are a couple more posts for you to enjoy. If that’s not enough, have a look at the full list.

  1. Avatars and alt text

    I really enjoyed Nicolas Steenhout’s recent article on Alt text for avatars or user photos. But there is a context where I would break his rule…

  2. Upgrading from iPhone 13 mini to 16 Pro

    I get a new phone every 3-ish years, give mine to my wife, and now she gives hers to our daughter. I got a 16 Pro this year! Here’s the skinny.