Reputation: 1876
Please understand the scenario:
1. created a new branch a day ago and pushed my work there.
2. worked on sublime whole day, modified existing files, created some new files.
3. Didn't add or commit, but stashed, switched to another branch, commited there and popped the stash
Whoa !! new files (untracked files) lost
Is this the normal behaviour of stash or I might get this data back.
Any help would be appreciated. Thanks :)
Upvotes: 9
Views: 6567
Reputation: 3546
You can include untracked files when stashing, e.g., using the -u
parameter, as mentioned already.
Just be aware, that untracked files do not show up when using just
git stash show <stash>
. For that, you also need to include -u
, just like when you stashed: git stash show -u <stash>
Upvotes: 7
Reputation: 11607
In step 3, you say you '... switched to another branch, committed there and popped the stash'. The only thing I can think of is, when you switched to the other branch, you committed the new files there, then switched back to your previous branch (where you were in step 2), popped the stash, and saw the new files were gone. In this case, the new files have been committed in the new branch you switched to in step 3, so you'll find them there.
Upvotes: 2
Reputation: 3784
Please use the -u option when you create your stash. Take a look on https://www.kernel.org/pub/software/scm/git/docs/git-stash.html
Upvotes: 7