Your Git stashes live in a stack

calendar_today timer Reading time ~1 minute

Did you know that Git stashes get piled up on top of each other like in a stack?

That means that every time you stash, Git bundles up all of the changes and puts them on top of the old stashes you already had.

If you run git stash list, you can see all of your stashes. And every single one of them has an index.

The new stash always on top will always have the index zero. And then one, two, three, and going back until you finish the stack.

That also means that when you do git stash pop without picking any specific stash, Git will use the latest one — always the stash of index zero.

Because stash works in the fashion of a stack, the last one in is always the first one out. And this is good to know, especially if you have more than one stash going.

Want the full stash workflow (pop, apply, and drop)? I covered it here: Using git stash: pop, apply, and drop

Follow along for more git tips like this!

animated jess' signature

Related Articles