git-stash gives “no valid stashed state found” errors on Windows
Posted by derek in Errors at 10:36 AMWhen 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: curly brace, error, fatal, git, stash, windows
Entries (RSS)
Have you tried using
git stashin the mSysGit shell or regular DOS prompt?[Reply]
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]
In a Powershell prompt, single quotes seem to work better:
git stash apply ‘stash@{1}’
[Reply]
alex Reply:
May 6th, 2010 at 10:26 AM
Hello Eric,
Thanks for taking the time to leave feedback. Do double quotes not work at all in Powershell?
Thanks.
alex
[Reply]
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]