Phpstorm: working with git branches and remote deployment

I have a PhpStorm project linked to a remote server (VM) where I set up auto deployment, so every time I change and save a file, it is automatically uploaded to that server. Now I want to use GIT for this project. My workflow should be as follows: - Working on a local copy - Save and auto upload to development server - Test (open web page on dev server) - if ok, commit from local copy. Then click, etc ...

My question is how to work with branches? I mean, I know that when switching a branch, the directory I'm working on might change completely. Example: my branch A contains a.html. My branch B only contains b.html If I switch the branch locally, the contents of my folder change. Will PhpStorm add / remove a.html / b.html on my deployment server every time I switch a branch? Obviously this is not what I want. How will these changes be reflected on the deployment server, how will PhpStorm handle this? Thank you for your help.

+3


source to share


3 answers


For something like this, you can approach in different ways. Here are a couple.

  • set up a cron job on the server to regularly checkout from the master, then you will need to use branches for each new task and merge them when they are done and the cron job will process it the next time the master starts.
  • if you prefer to handle this in phpstorm you can create a bash alias in your .bashrc or .bash_profile to ssh on the server and do a pull (I named my alias "deploy") then you can run the command in the built-in terminal in phpstorm.


I prefer the second method as I don't have to wait for cron to do this and I can see when an error occurs, like some sort of merge conflict.

0


source


I was able to solve this problem by opening an ssh window with a remote environment. Just create a branch and checkout on the remote server. Now all changes that you upload via phpstorm will be considered as changes in this branch. You can save and view the results in your browser.



0


source


PHPStorm GIT will only use your local copy. This has nothing to do with deployment. PHPStorm does not have to pass its own configuration files within a project. You can check it out on Settings -> Version Control -> Ignored Files

where it should specify the folder .idea

and file ending in .iws

. Of course, you could also add other ignore files (e.g. your own config files)

If you are using GIT in the CLI (not in PHPStorm), you must create a .gitignore file containing to ignore the PHPStorm config files:

/.idea
*.iws

      

PHPStorm only needs to sync switch branches when Upload external changes

enabled in the deployment options, since GIT is external.

-2


source







All Articles