Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in DevOps and Agile by (29.3k points)

I have 2 branches: master | design

Working in design I did a stash and switched to master, made some adjustments. Switched back to design and did a stash apply only to lose all my changes in the design branch.

I am hoping all my work is within a stash as I have not cleared or removed these.

If I do a stash list I get 4 results:

[email protected]{0}: WIP on design: f2c0c72... Adjust Password Recover Email

[email protected]{1}: WIP on design: f2c0c72... Adjust Password Recover Email

[email protected]{2}: WIP on design: eb65635... Email Adjust

[email protected]{3}: WIP on design: eb65635... Email Adjust

If I try git stash apply f2c0c72 I am getting an error:

fatal: Needed a single revision

f2c0c72: no valid stashed state found

How can I apply a specific stash?

2 Answers

0 votes
by (50.2k points)

For this question try:

git stash apply [email protected]{0}

In some shells like zsh,powershell there you need to quote “[email protected]{0}

Since version 2.11 this became pretty easier  you can use ‘N’ stack instead of ‘[email protected]{n}

The command for this is:

git stash apply n

This is how you can stash apply in git versions.

To get the list of stashes you could use:

git stash list

0 votes
by (62.9k points)

To apply a stash and remove it from the stash list, run:

git stash pop [email protected]

To apply a stash and keep it within the stash cache, run:

git stash apply [email protected]

Related questions

+4 votes
1 answer
+1 vote
1 answer
0 votes
1 answer
asked Aug 2, 2019 in DevOps and Agile by Han Zhyang (19.7k points)
0 votes
1 answer
0 votes
1 answer

Browse Categories

...