Ways to sync your code from PyCharm to a remote Linux server
No wording, stright to the problem
Introduction
I am not a fan of long wording so let’s jump straight into the problem.
Have: a PyCharm project, a remote Linux server (SSH)
Want: sync the project to Linux
There are three ways I know of. Let’s go straight to the one I recommend and you can read the rest later.
Use PyCharm’s Deployment
At the time of writing, I am using PyCharm Pro version 2021.2.3. I am not sure if this function is available in other versions. The tutorial is adapted from: https://blog.csdn.net/zhaihaifei/article/details/53691873
- Select
Tools => Deployment => Configuration - Press the
+icon to add new Deployment. - Choose
SFTF. (I don’t know what this is though) - Choose a name for your deployment. Any name.
- Select the three dots thing on the right hand side of the
SSH Configurationtab. - Click the
+icon to add new SSH configuration. Then input your host, username and password there. The SSH is usually given in the formatusername@host. Remember to test connection. Then selectOKto apply the connection. - In the currently opening window, select
Mappingon the top middle, then change theDeployment pathto the path you want to upload. The path will becd-ed to. The deployment will behave as follows: Server login =>cdto this path => Sync code. - Click
OKto close the window. - (Optional) To sync the code on
Ctrl+Sclick, go toTools => Options => Upload changed files to.... Select this asOn explicit save action (Ctrl+S). - On the Project tree on the right hand side of PyCharm, click the whole project’s folder (or just the folder/file you want), then select
Tools => Deployment => Upload to <yourServerName>. The code will be uploaded to the server.
And that’s it for this method. Fastest to configure in my opinion.
Use GitHub
I do not recommend this method. The method is to upload the project to GitHub, clone it to the server then git pull every time the code is updated. It is the easiest but will consume a lot of your time.
Use JetBrains Gateway
Link: https://www.jetbrains.com/help/pycharm/remote-development-a.html. Depends on you. Method #1 is sufficient to me.