PowerShell is a powerful modern shell for Windows. However, it is not without its quirks. As a modern software developer on Windows you use PowerShell on a regular basis. Sometimes CLI applications (I’m looking at you git) interact with PowerShell in quirky ways. I saw this the other day with git in PowerShell.

I was trying to git diff my current changes with the ones in my latest stash stash@{0}. However, when I ran the command git diff stash@{0}, I got the following error:

fatal: ambiguous argument 'stash@': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]

Oh no what happened?! From the git error message, it gives a clue as to what went wrong: ambiguous argument 'stash@', but I typed stash@{0}!. PowerShell has interpreted the curly braces in an unexpected way. The shell is eating my brackets šŸ“šŸ’»

The issue is that indeed PowerShell is interpreting the curly braces, not as text but as syntax. This issue will occur when you interact with your stash stash@{X} (e.g., git stash apply stash@{0} would have been an issue too).

On Windows, this is not an issue with Command Prompt but with PowerShell only.

Fixing ambiguous argument 'stash@' error

For PowerShell the fix is simple: put the stash@{0} into single quotes 'stash@{0}'. A few examples:

# Best and easiest fix
# Just put in single quotes
git diff 'stash@{0}'

# Double quotes work too:
git diff "stash@{0}"

# The issue is really only
# the curly braces,
# so we can be...

# Fancy šŸ¤µ
git diff stash@'{0}'

# More fancy šŸ¤µšŸ¤µ
git diff stash@'{'0'}'

# Even more fancy šŸ¤µšŸ¤µšŸ¤µ
git diff stash@`{0`}

Other Causes

Another cause can be from using a branch called stash or a remote named stash. I would avoid calling your branches any git related keys words šŸ˜œ