Tuesday, 12 November 2013

How to pop a git stash that was not the last stashed

Doing

git stash pop

pops the last changes that were stashed.

However, if you want to pop a git stash that was not the last one stashed, you need to use

git stash pop [email protected]{n}

For example, when following are the stashes (given by git stash list):

[email protected]{0}: On master: Uncommitted changes before update operation at 04/09/13 9:02 AM
[email protected]{1}: On refactor: Checkout migration at 09/07/13 1:20 PM
[email protected]{2}: On refactor: Checkout migration at 09/07/13 8:54 AM
[email protected]{3}: On master: Checkout refactor at 08/07/13 11:00 PM
[email protected]{4}: On refactor: Checkout master at 08/07/13 10:59 PM
[email protected]{5}: On master: Checkout bug-456231 at 05/07/13 9:37 AM

[email protected]{6}: WIP on master: 154bb0f Merge branch 'refactor4'

the following command pops and applies [email protected]{3}:

git stash pop [email protected]{3}
Post a Comment

Flattr this blog