I went into a branch and did some work. I wanted to go into another branch but didn't want to commit so I did git stash
. Then I did git checkout <otherbranch>
. I did some work there and, just like in the first branch, I wanted to switch out of it before committing the work. So I did git stash
there too. I switched back to the first branch and tried to unstash it (git stash pop
) thinking it would get the stash from that specific branch. I was surprised that it unstashed the stash from <otherbranch>
(latest stashed). I was under the impression that stash is branch-specific but this behavior indicates that there is only one stash for the whole local repository.
Is git stash
branch-specific or for the whole repository? If it is for the whole repository, can I pass options to it to make it branch-specific?
No and No. git stash is per-repository.
Here is a nice page on how to use it.