Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Phpstorm : working with git branches and remote deployment

I have a PhpStorm project linked to a remote server (a VM) where I set automatic deployment, so each time I modify and save a file, it is uploaded automatically to this server. Now I want to use GIT on this project. My workflow should be the following : - Work on local copy - Saving and automatic upload to the development server - Test (open webpage on dev server) - if ok, commit from local copy. Then push, etc...

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

like image 779
Tinostarn Avatar asked Nov 23 '22 11:11

Tinostarn


2 Answers

For something like this, you can approach a number of different ways. Here's a couple.

  1. set up a cron job on the server to regularly pull from master, then you would have to use branches for each new task and merge them when they are done, and the cron job will handle it on next pull of master.
  2. if you prefer to handle this in phpstorm, you can create a bash alias in your .bashrc or .bash_profile to ssh into 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 it's thing and I can see when an error occurs such as a merge conflict of some sort.

like image 114
DWils Avatar answered Dec 03 '22 01:12

DWils


Just in case someone is looking for the solution:

Tools > Deployment > Options

Uncheck Skip external changes

Please Note: Option Automatic Upload (always) must be checked

like image 29
user3841429 Avatar answered Dec 03 '22 02:12

user3841429