Git Branches: deploy to different locations
已回答
Hi there,
is it possible to deploy git branches to different servers?
For example:
Got a repo with 2 branches: develop and master.What I need is PhpStorm to deploy changes depending on the current branch to a specific server (branch master to master.example.com and branch develop to develop.example.com)
Please let me know if it's possible or if there exists a workaround for this problem!
请先登录再写评论。
Hi,
I have similar request here for Python development.
I would like to use two different servers and interpreters in order to develop upgraded version of my project. New branch will use new python librairies on a more recent server. The other branch is maintained for bug fix on existing environement.
Deployment configs are stored in the .idea/deployment.xml file within the project. So It is possible to put different versions of the file to different branches, and then switching a branch will also switch the deployment settings.
Thank you for you swift answer.
I can see config file, but how can I make the link between branch and deployment file ?
Should I commit deployment.xml according to each branch ? Usually I ignore .idea/* files on Github.
> Should I commit deployment.xml according to each branch ?
Yes, that's the idea. Even if the .idea folder is ignored, you can force add this specific file.
Got it ! Thanks for the tip :)
We have a similar setup in our team: one repository with 2 branches ("dev" and "master") that should be deployed into two different folders on the dev-server ("html-dev" and "html-main")
but: every developer has his/her own dev-servers (mine is "dev-dunstheimer") , and the server-name is also stored in deployment.xml
how would I do this? :)
Andreas Dunstheimer
You can utilize synchronous repository control:
Init a repo in the .idea folder, add the same branches as you have in the main repo, and add the corresponding deployment.xml to them. So your project will have 2 repos - the main one with code, that is shared, and the local one with your .idea/deployment (and other configs if needed).
Make sure the repo in the .idea folder is correctly recognized in the IDE, add a mapping in Settings | Version Control. Then enable Execute git operations on all branches in Settings | Version Control | Git.
This way, along with switching branch in the main repo the version of deployment.xml will be also switched.
This of course should be set up locally for everyone.
sounds promising - thanks for that quick answer !
"switching a branch will also switch the deployment settings."
The problem is the deployment settings are loaded into memory when PHP is loaded. If you switch branches from within PHPStorm and it updates the deployment.xml file, those changes are not recognized unless you restart PHPStorm.
Does anybody know a way to update the deployment mappings after switching branches within PHPStorm without restarting PHPStorm?
Are you switching branch with PhpStorm or externally via Terminal?
If via Terminal, does File | Synchronize make it upload after branch switching?
Ignore my comment above. I tested by manually changing the deployment.xml file and didn't see it update in PHPStorm. I've since created the git repo for my .idea settings and it works as described. Apparently when switching branches in PHPStorm it automatically refreshes the settings from the file system. Thanks!