Changing git branch on remote server

Answered

I've cloned a git repo to my local dev machine, and did the same on my remote deployment server. I setup automatic upload of any local changes (on save). However, I just noticed that when I do git pull locally, or switch branches locally, these changes are not reflected on my deployment server.

Is there a way to configure such git integration?

9 comments

And why do you use git on a deployment server at all? 

Basically, you do not need any versioning on the deployment server, you just need a copy of the code in your working directory.

This is exactly what the Deployment feature does. Note that external git client is used for git integration, so changes done by git are external for the IDE - thus you need to enable the Upload external in Deployment Options

-2

Thanks Dmitriy, I guess "Upload external changes" option helps to achieve this.

However the difference between branches might be significant (in my case, dozens of files, with potentially large files needed to be copied or deleted when switching). It seems to me that having PyCharm send a single "git checkout branchname' command instead of trying to sync the entire local repo state would be much more efficient.

Having identical git state on both local and remote machines seems to be a cleaner, more elegant solution. Are there any downsides to this approach?

0

Synchronizing via git is far more complicated.

Now, IDE just syncs whatever files it has in the project directory to the remote location, specified in settings. It is sImple and VCS-independent and allows handling all kind of changes - manual, VCS checkout, external copying, etc... It allows you to test changes on a deployment server before actually committing them.

The git-related approach will actually provide only one advantage - potentially less traffic between hosts. On the other hand, I  see the following drawbacks:

  1. The feature is VCS specific, however, does not fit the Git Integration in general. So this will probably need a separate plugin or special logic in the Deployment.
  2. It is more elegant only in case of branch switch, assuming the repo state on the remote is the same as yours. But if you have some changes you want to get to the remote, you have to commit them first, then push. It is even more complicated if you use a central repo - you will need to push your changes there and pull them on the remote host.
  3. It is not possible to push to branches that are checked out by default, thus you will not be able to deploy changes within the same branch using this approach
  4. It is harder to setup - you need to clone a repo on the remote host, so you need to actually get there via SSH first.

I believe there are many more drawbacks than advantages.

 

0

Ok, I see. I think the option or plugin to replicate those git commands that modify local repo state on the remote server still has value, but for now "Upload external changes" option is good enough for me.

By the way, what do you think about having PyCharm edit remote files directly? Currently to do this I have to mount remote file system locally using Win-SSHFS, which is extremely unstable, even when plain ssh works fine. Is there a way to do this without mounting the remote repo locally? Something like remote-atom: https://atom.io/packages/remote-atom but better integrated into IDE.

I'm working on two research projects (separate codebases, running simulations on up to 5 remote servers), and I do development on a windows laptop. If win-sshfs worked well, I'd just keep 5 mounted folders for those servers, and would be happy. But it doesn't, that's why I have to deal with the remote interpreters, and having to sync all my local changes with all those 5 servers.

0

Perhaps, but I'm not talking about right-click menu for a local file. I don't see the need to keep a local copy. Basically what I want is the same functionality as when I'm opening ssh connection to remote host, then editing a file there with vim, only done through PyCharm IDE. So that when I click on the file in the project tree structure in the left panel, it opens the remote file for editing, not the local copy.

0

Please sign in to leave a comment.