Confused on switching branches with git stash and shelve
Answered
It's currently too cumbersome for me to switch branches in a git repo in PHPStorm where I want to bring up the file tabs from the branch I'm switching to... I can currently switch branches and shelve (in PHPStorm so it remembers my file tabs), or switch branches and stash (in GitHub Desktop, which lets me stash with a click), but switching branches in PHPStorm doesn't stash changed files.
What am I missing here?
I've been through docs and settings and I'm not seeing how to do it all in PHPStorm by checking out another branch; it seems this should all be automatic for the convenience of the developer.
Please sign in to leave a comment.
I noticed I have existing shelved files in the Git Shelf tab, but they don't appear to be tied to any branch... even though I made the changes on a certain branch, and only make sense as the working copy of that branch.
Hello Vadiru
I am sorry, but could you please clarify - do you want to keep opened tabs across all branches?
There is an option "Restore workspace on branch switching" under Preferences | Version Control | Confirmation
It makes IDE to remember what tabs were opened on particular branch, you can disable it and then you will always have same tabs opened across all branches.
As for stashing changes you may find "Smart checkout" useful
> do you want to keep opened tabs across all branches?
No, that's the default behavior when checking out a branch from anywhere other than PHPStorm. I want the opposite, but with stash/unstash as well.
When I switch branches in PHPStorm > Git panel > Log tab (by right-clicking the branch I want to switch to then selecting Checkout), I want the file changes in the git repo's working copy to stash, then I want the open tabs/panels in the editor to shelve, then I want the branch to checkout, then if there is a stash for that branch, I want it unstashed, then I want the tabs/panels previously shelved for that branch to open.
This is a matter of developer convenience, which PHPStorm does better than other editors for many many things.
I can get it merely to shelve/unshelve on branch switch, but not stash/unstash. I have to stash in Terminal, then go to Git panel > Log tab > right-click branch > Checkout. I'm not seeing how to get it to stash/unstash as well.
Hello Vadiru
There is a similar request, please feel free to vote for it:
https://youtrack.jetbrains.com/issue/IDEA-90151
Stash/Unstash can be done via Git menu (Git | Uncommited Changes)