Posted over 2 years ago. Visible to the public. Repeats.

Git stash: Working with old Entries

First find the reference for the entry you want through looking at the stash:

$ git stash list stash@{0}: WIP on feature/foo stash@{1}: WIP on feature/bar stash@{2}: WIP on fix/baz

Now you can simply use that reference, but curly braces must be escaped:

git stash pop stash@\{1\}

or quoted:

git stash apply "stash@{1}"

Quick reminder to not shoot yourself in the foot:

  • apply applies the entry to the working directory but will not delete it from the stash
  • pop applies and deletes the entry from the stash (only if there were no conflicts when applying it)
  • drop will only delete and not apply the entry

Running these commands without a reference will use it with the last entry.

Partial stash pop

Sometimes you only want to pop parts of the stash. Do this the way vice versa:

git stash pop git stash -p # Now move all the unnecessary parts back into the stash

With tig

tig offers an easy way to browse through the contents of your stash as well: tig stash. Navigating works as expected.

Growing Rails Applications in Practice
Check out our new e-book:
Learn to structure large Ruby on Rails codebases with the tools you already know and love.

Owner of this card:

Judith Roth
Last edit:
9 months ago
by Judith Roth
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Judith Roth to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more