When using git-stash from a Windows command prompt, I would get errors when trying to manipulate stashes.

For example, after running “git stash” to create a stash, if I later listed the available stashes with “git stash list” (which would return something like “stash@{0}: WIP on mybranch: 669dc9c… My comments”) and then tried to apply the stash with “git stash apply stash@{0}”, I would get the error “fatal: Needed a single revision
stash@0: no valid stashed state found”.

I noticed that the curly braces were missing in the error message, so I had to escape them with “git stash apply stash@\{0\}” to get the command to work.

I also got this error when trying to drop or pop a stash (e.g. “git stash drop stash@{0}”), and had to escape the curly braces here as well.

Tags: , , , , ,
5 Responses to “git-stash gives “no valid stashed state found” errors on Windows”
  1. patelc75 says:

    Have you tried using git stash in the mSysGit shell or regular DOS prompt?

    [Reply]

  2. derek says:

    I was using PowerShell, but I also tried it from a regular DOS prompt. Does it work without the escape characters in a Git Bash shell?

    [Reply]

  3. Eric Lee says:

    In a Powershell prompt, single quotes seem to work better:

    git stash apply ‘stash@{1}’

    [Reply]

    alex Reply:

    Hello Eric,

    Thanks for taking the time to leave feedback. Do double quotes not work at all in Powershell?

    Thanks.
    alex

    [Reply]

  4. Eric Lee says:

    Yes, double quotes appear to work too. I hadn’t tried them when I left the first comment. The basic issue is that in Powershell the curly braces denote a script block so Powershell is hijacking them and not passing them on to git as simple characters. Either single or double quotes prevent that.

    [Reply]

  5.  
Leave a Reply

*Type the letter/number combination in the abvoe field before clicking submit.

*