What happened
git stash pop
should have reapplied all your changes to your working tree. Something else which you are not telling us about might have happened.
Note that, in order to get "everything as it was" back, including the state of the index if you have already staged some changes, you have to run:
git stash apply --index
git stash drop
The --index
flag, not available with git stash pop
, restores the index.
If you did not have staged changes or if you did not care about restoring the index, what you did is correct. So there must be something else.
Alternative workflow in your situation
Something else that you could have done, once you realized that you were making changes on the wrong branch is:
- Move HEAD to branch B without touching at the working tree or the index:
git reset --soft B
So now HEAD points to branch B but your working tree and index haven't changed and thus still contain the changes you made while you were on the wrong branch.
- Finish your changes, stage them, and commit them
For instance:
git add .
git commit -m "..."