Does Visual Studio Code support code sync with remote server?
Asked Answered
J

2

11

Please help me to understand something about Visual Studio Code. I spent already days searching and testing this tool and still, can't make it work like I want. Before I worked in Netbeans and it supports local directory content and file changes sync with remote server. If I create or change a file, it will be sent to remote server. I want the same in Visual Studio Code, but I can't find how. I know, that there is Visual Studio Code Remote - SSH, which allows to directly change remote files, but I want to have local copy. And then there is Sync-Rsync extension, which almost do what I want, but not exactly. It allows to send changed files to remote server, but totally ignores file and folder creation or deletion. Or maybe I just do not know, how to configure it, to work correctly. Maybe someone have more experience with this and can share some thoughts about this?

Justin answered 10/3, 2021 at 17:23 Comment(11)
I don't use VS Code, but I think most IDEs call this "deploying". Look for this in the menus.Externalize
Can you use git to sync with remote server ?Goingover
VSCode doesn't actually do lots by itself. Most of the functionality is actually provided by plugins. You probably need a find a suitable plugin (although combining this with source control by using git with a remote repository mapped is potentially a very good solution for you, and a very common setup)Joung
Yes, there should be some extension, that does, what I need. My problem is only, that I don't know, which one. All I tried so far, was only partly doing, what I need. VSCode have deployment extensions too, but I think, they do not provide automatic synchronization with my actions.Justin
My problem is only, that I don't know, which one. ... We'll fine, but please understand that this site isn't a free do-my-research service. If someone happens to know just the exact thing, they might mention it, but realistically it will be faster for you to study it yourself. Do explore the git idea though, it's a good one. Many developers do that, as a way to backup their code and simultaneously version-control it. It can also be used as a deployment method too.Joung
@Joung Yes, this is site, where developers can share their knowledge, right? I thought, that is what I'm asking here. And I really do not know, how version control system can help me here. I'm working with php code and not all changes I want to see in version control. But all changes I want to see on remote server, to tests them right away.Justin
I thought, that is what I'm asking here....sure, but giving recommendations for things like 3rd-party software is specifically off-topic - see What topics can I ask about here? for the source of that info, and the reasons why that rule exists. So that's why I mention it's better to do your own research into available plugins.Joung
I'm working with php code and not all changes I want to see in version control... why not? You can (and should) create feature branches for just testing things out or developing individual or experimental stuff. And you can also easily roll back any commits you no longer want. Either that or run a local PHP server where you can immediately run your changes without having to push them anywhere, before you decide to commit them to source control.Joung
@Joung "Questions asking us to recommend or find a book, tool, software library, tutorial or other off-site resource are off-topic" - yes, and I'm not asking now "Tell me your top 10 extensions". I just explained, what I tested so far, to fix my issue. Hah, and it's you, who insists, that I should use 3rd-party software for this goal, and not VSCode itself. Anyway, this conversation is really off topic. Will continue my research too. Don't worry.Justin
I'm not asking now "Tell me your top 10 extensions"...no, but I explained that VS Code is primarily implemented via extensions, so to find the functionality you're looking for you need to find an extension. Then I explained you needed to research it yourself, you then asked why we wouldn't share such knowledge, so I explained that it's off-topic. it's you, who insists, that I should use 3rd-party software for this goal...yes because VSCode doesn't have the functionality you want out of the box. Anything like that is done via extensions. I'm not really seeing your point.Joung
Anyway the configuration options for the rsync plugin is all here: marketplace.visualstudio.com/… . There's clearly an option you have to set if you want it to delete files. We don't know if you set that option, or what other options you have set or not set which might cause it to ignore subfolders. Why it ignores new files is a mystery too - show us the current config if you want more help with that.Joung
C
10

A reasonable question, IMO! This response is undoubtedly too late to help OP, but hopefully it will help others. I have been frustrated with the same problem, and I have used the SFTP extension by liximomo, which seems full-featured and reasonably well documented. It's worked OK for me, and it has >1M downloads with 4-star reviews based on 225 reviews. Unfortunately not updated since 2019, and recent reviews have not been good. There are several other extensions of the same name with fewer downloads and reviews. This one looks promising: it is a fork of the liximomo project, last updated 8 days ago, almost 30K downloads, and 22 reviews with a 5-star average. Actually, seeing this, I think I will uninstall the liximomo version and install this one, thanks for getting me to look into this.

[Edit Feb 2022: the extension I said I would try was SFTP by Natizyskunk. It now has 42K downloads, and 26 reviews with a 5-star average. When I just checked it was literally updated yesterday, the first time since a burst of updates last November. I don't use it a lot, but it's worked fine when I have.]

Sync-Rsync has about 26K downloads, 4.5 stars based on 21 reviews. The changelog is also 2019-vintage.

Clarendon answered 30/11, 2021 at 13:44 Comment(2)
This seems so strange to me that there is no native vscode feature for this.. I just stumbled across this issue and I don't get why people would ever prefer remote ssh over a local copy that is synched in the background.. imagine you have to travel someday and on the way, you have a bad connection. Remote ssh is a really crappy solution.Dearing
Still not quite there, because if you want to debug your code running on the remote machine you will need to launch two instances of VScode, one local and one ssh-ed to remote.Shorn
S
0

You can use sftp extension by Satiro Marra. It will create, update, delete, rename remote files as in Netbeans. But this is not default behavior, you need to add config as below.

 "watcher": {
    "files": "**/*",
    "autoUpload": true,
    "autoDelete": true
  },
"uploadOnSave": false,

or full example config file :

    {
    "name": "My Server",
    "host": "1.1.1.1",
    "protocol": "sftp",
    "port": 22,
    "username": "username",
    "password": "pass",
    "remotePath": "/full_remote_path",
    "watcher": {
        "files": "**/*",
        "autoUpload": true,
        "autoDelete": true
      },
    "uploadOnSave": false,
    "useTempFile": false,
    "openSsh": true
    }
Seducer answered 1/4, 2023 at 11:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.