0

When I run git stash list, I get the following:

stash@{0}: WIP on mybranch: 123456f Generic comment here.
stash@{1}: WIP on mybranch: 234567g Generic comment here.
...
stash@{n}: WIP on mybranch: 345678h Generic comment here.

This is expected behavior. What mystifies me is git show's behavior.

When I run git stash show -p stash@{1} in my repo, I get the following error:

fatal: ambiguous argument 'stash@{1}': unknown revision or path not in working tree.

How can this be? I'm running git stash show -p stash@{1} in a git repo.

lolololol ol
  • 848
  • 1
  • 8
  • 18
  • That does seem impossible. It means `git rev-parse` is failing to translate `stash@{1}` into a Git object ID, and yet `git stash list` simply shows all the reflog entries for the `stash` ref, so if it shows `stash@{1}` then `stash@{1}` is a valid name for an object ID. (The "on the right branch" part is irrelevant: stashes are on *no* branch.) – torek Jan 10 '17 at 21:14
  • What Git version shows this error and with what Git version was the repository created (cloned)? – try-catch-finally Jan 10 '17 at 21:26
  • `git version 1.8.0` for both showing the error and the repo it was created. – lolololol ol Jan 10 '17 at 21:48

1 Answers1

1

The shell was eating up my own curly braces.

git stash show -p stash@'{1'} works.

Ironically, it was the least upvoted answer @ Is it possible to preview stash contents in git? that answered my question.

Just weird because the error reported the command with curly braces. You'd expect it to report it without them.

Community
  • 1
  • 1
lolololol ol
  • 848
  • 1
  • 8
  • 18
  • 1
    In fact, my shell does that as well, but the error message *does* show it without the curly braces: `fatal: ambiguous argument 'stash@2': ...` It seems impossible. What OS are you on (and why is your Git so old? :-) these may have the same answer...) – torek Jan 10 '17 at 22:29