0

I used the following command to git stash save with tracked and untracked files

git stash save -u

But I was trying to use git stash apply stash@{0} to apply the changes, the untracked files were only restored, however, the tracked files were not restored. I used git stash show stash@{0} to check the all tracked files available still in the stash.

How can I apply the tracked files from the stash then?

Lei
  • 51
  • 6
  • This is contrary to my experience, including a test I just ran to make sure. So that makes me wonder if there's a misunderstanding around what "tracked files were not restored" means. Can you be more specific about what was in your work tree and index (especially wrt uncommitted changes to tracked files) before stashing, before applying the stash, and after applying the stash; and in what way this didn't match your expectation? – Mark Adelsberger Dec 28 '17 at 15:55
  • @MarkAdelsberger, There were some tracked and untracked files to be stash save, the first command saved all these files into stash{0}. After, I want to apply these changes and 'git stash apply stash@{0}' to retrieve them but ONLY untracked files were retrieved NOT the tracked files. not sure why?? – Lei Dec 28 '17 at 15:59
  • That doesn't really answer the question. It seems to me you've only repeated what you'd already said. I suspect there is a misunderstanding about what stashes do, and I can think of at least a couple possibilities for what the misunderstanding would be. But I'm not running through detailed explanations of every possibility. I'll be happy to try to help, if you provide the *additional detail* requested about what was in your work tree and index before stashing, before applying the stash, and after applying the stash; and a specific example of how this varied from your expectation – Mark Adelsberger Dec 28 '17 at 16:36
  • Not 100% the same, but the answer applies: https://stackoverflow.com/q/20586009/1256452 – torek Dec 28 '17 at 16:43

1 Answers1

-1

Use git stash pop instead of git stash apply to make all tracked and untracked files to be retrieved.

Lei
  • 51
  • 6