Remote changes to automatically sync locally?

Answered

Very possible I'm just a dummy here, but I've searched the manual and haven't found anything there about this yet.

Here's my situation:

New job. Dev environment is a jail on a FreeBSD server. I've tried setting PhpStorm up with both SFTP and mount and I still have the same problem. Problem is that when the remote files change (git pull, git checkout to revert a file, whatever...) they don't update automatically on local. I understand that you can right click and select "Sync from deployment server", but TBH, I'm not too stoked on that.

Best approach I have so far is to do File > Open Directory on the mount. Remote file changes show up when doing it that way, but then PhpStorm's syntax highlighting takes a while to catch up. Likely because it's always trying to index in this situation. Not to mention the file path case sensitivity issue that PhpStorm always brings up when I use this route.

Any pointers?

Thanks.

7 comments
Comment actions Permalink

Hi there,

This IDE is built around different idea -- local code first, remote is secondary. This means: you work with your files locally and then upload to remote server (e.g. manual or automatic deployment via FTP/SFTP/mounted drive/folder etc) or push to VCS (in later case this also mean that you would need to pull from VCS on remote as well).

If you have everything remote .. then your "File > Open Directory on the mount" would possibly be the best way, although lags and random short freezes are possible here (really depends on your system and environment; IDE needs really fast access to source files and network connection is usually much slower than local SSD (or even HDD)).

I guess https://youtrack.jetbrains.com/issue/WI-1284 is what you are after -- watch this ticket (star/vote/comment) to get notified on progress (which, based on ticket history, is rather unlikely to have any soon).

As a possible alternative (when working with files locally) -- consider using some sync soft outside of IDE -- see if you can use RSync -- it seems to be much faster than what IDE can offer right now.

0
Comment actions Permalink

But why does it with local code first them remote approach ignore the .git and other metadata folders and files when setting up a project based on existing remote files. This effectively prevents local git operations without further manual configuration. And what about operations available only remote, like drush dl or drush up?

1
Comment actions Permalink
But why does it with local code first them remote approach ignore the .git and other metadata folders and files when setting up a project based on existing remote files.

Because such files/folders are part of default "exclude in transfer" settings: "Settings/Preferences | Build, Execution, Deployment | Deployment | Options --> Exclude items by name". Surely, such setting (default names listed there) usually makes sense to be applied to uploads only .. but it is what it is.

If you need such folder copied from remote .. then I may suggest such alternatives (if it can be called this way):

1) configure project default settings (that would apply for every future new project) and remove such names from the aforementioned field. Default settings are accessible via "File | Default Settings..."
2) or create empty local project first .. and instead of using New Project wizard .. just configure deployment manually and download all files you need -- similar to the above but allows you to make such changes to current project only.
3) same as #2 but download project using any 3rd party software (even Windows Explorer if you can access remote via shard folder/network).
4) same as #3 but swap the steps around: make local copy first and then just use "Open Directory" in IDE to open it as a new/existing project.

And what about operations available only remote, like drush dl or drush up?

You can execute them via Remote Terminal from within an IDE.

But yes -- if it can be run on remote only .. then I don't really see other option as to run it remotely and sync changes back (although, since I do not have any real experience in this particular setup (have not faced it in my projects so far; I mostly work with code that can be easily run locally) .. possibly that it can be some somehow differently). Maybe somebody else can give you a better advice on this part.

0
Comment actions Permalink

Yup, that issue is exactly what I'm after.

Thanks, Andriy.

0
Comment actions Permalink

He changes code and then the remote code changes essentially immediately without the need to run any commands. How is this done in PyCharm?

I am not sure if I understand you right, but most probably the changes are being copied to the remote side via a deployment configuration with Deployment | Options | Upload changed files automatically: Always On

0
Comment actions Permalink

Eugene is right,

PHPStorm has config options for your deployment and there are many other plugins or outside tools to automate production 2 local...like 

1. Andriy suggestion is probably best, I would use rsync...maybe like this  https://github.com/aalto-ics-kepaco/fswatch-rsync

2. in the git admin you could setup a post-receive url aka "hook" action that could update your local branch

3. Travis, Jenkins, Circle, AWS Dev Something , Symphony, Capistrano, or other ci/cd's probably have options for you to reverse deploy 

4. Depending on your setup, you could possibly setup a local server as a "Slave" to the remote master that syncs via cronjob

 

For us, when change on remote , we push it to git

then we just pull latest to local branch before starting....usually takes a minute or 2 with our big ol app (~ 20,000 files)...we could automate the pull but don't want to so that we can manage merge conflicts for local changes that haven't been pushed

0

Please sign in to leave a comment.