0

At first branch is in master,then

(1) git checkout -b test1 ,then modify one file a.c,and git stash

And now git stash list

stash@{0}: WIP on test1: 7aa1dbd Merge "RR:AA123"

(2)git checkout -b test2,then modify another file b.c,and git stash

And now git stash list

stash@{0}: WIP on test2: 7aa1dbd Merge "RR:AA123"
stash@{1}: WIP on test1: 7aa1dbd Merge "RR:AA123"

(3) now git checkout test,and i'd like to get the modified a.c file,which was in stash@{1}

 git stash apply --stash@{1},

and found get the b.c but not a.c

do i miss some steps that try to get stash pop?

Alexis King
  • 40,717
  • 14
  • 119
  • 194
liumilan
  • 345
  • 1
  • 4
  • 12

1 Answers1

4

You should use

git stash apply stash@{1}

NOT

git stash apply --stash@{1}

--stash@{1} will be ignored as an invalid option, so it is equal to git stash apply

pktangyue
  • 7,546
  • 7
  • 43
  • 70
  • fatal: ambiguous argument 'stash@1': unknown revision or path not in the working tree. Use '--' to separate paths from revisions – liumilan Jan 24 '13 at 06:45
  • @liumilan It is `stash@{1}` not `stash@1` – pktangyue Jan 24 '13 at 06:48
  • I change shell from tsch to bash ,now git stash apply stash@{1} can work.Why it can't work in tsch? – liumilan Jan 24 '13 at 06:56
  • @liumilan from the error message, tsch convert `stash@{1}` to `stash@1`. And why this happend, I really not know. – pktangyue Jan 24 '13 at 06:59
  • I don't use `tcsh`, but I imagine the shell is interpreting the curly braces. You could probably single quote the argument and that would work: `git stash apply 'stash@{1}'`. – John Szakmeister Jan 24 '13 at 10:33
  • This answer (http://stackoverflow.com/a/6468931/602716) explains how the different shells handle the braces. – davidwebster48 Jan 20 '16 at 11:32