FTP-Sync extension
Auto sync your work to remote FTP/SFTP server (Łukasz Wroński)
安装此扩展实现在 Visual Studio Code 编辑 Shell 脚本后自动同步到远端环境,新建 Shell 文件,Ctrl + Shift + P 打开所有设置,输入:ftp,选中:Ftp-sync init 初始化配置,但提示如下:
命令”Ftp-sync: Init”导致错误 (Cannot read property ‘0’ of undefined)
Cannot read property ‘0’ of undefined error caused by “ftp-sync: Init”
原因是首先要打开本地文件夹(可以是项目文件夹亦可是空文件夹)后,才能在执行 Ftp-sync init 后,在此文件夹创建 .vscode ,进而在 .vscode 下创建 ftp-sync.json 配置文件。打开资源管理器快捷键(Ctrl + Shift + E)
local to Remote 启动一个向导,把本地文件同步到远程,用于手动同步。 Remote to Local 启动一个向导,用于把远程文件同步到本地。 Sync Current file to Remote 同步当前窗口文件到远程机器。 Upload file/Folder 上传文件、文件夹。 Commit 查看本地和远程文件的差别,然后同步。 有如下几种方法来同步: 1、如果"uploadOnSave"设置为true,每次保存文件的时候会自动同步(如果无效,请关闭vscode后重新再打开,就可以使用了) 2、在左侧文件列表中选择要同步的文件,右键选择:Ftp-sync: Upload File 3、Ctrl + Shift + P 然后选择 Ftp-sync:Sync Current file to Remote
{
"remotePath": "/home", //远程服务器脚本路径
"host": "1.1.1.1", //远程服务器 ip 地址
"username": "username",
"password": "password",
"port": 22, //ftp的默认端口是21,sftp默认端口是22
"secure": false,
"protocol": "sftp", //默认是ftp,根据自自己情况,可以填写ftp和sftp
"uploadOnSave": true, //默认是false,建议设置成true,这样每次修改后ctrl+s保存后会自动同步。否则就需要手动同步
"passive": false,
"debug": false, //默认是false,如果设置为true,可以看到通过菜单的 查看->输出 打开输出界面,看到打印,怀疑自己连接有问题的可以打开看看
"privateKeyPath": null,
"passphrase": null,
"agent": null,
"allow": [],
"ignore": [ //忽略同步的目录和文件
"\\.vscode",
"\\.git",
"\\.DS_Store"
],
"generatedFiles": {
"extensionsToInclude": [
""
],
"path": ""
}
}