VSCode 修改代码后,使用SFTP插件自动同步到远端服务器
1.安装SFTP插件
在线安装:搜索插件 SFTP(Natizyskunk),安装
离线安装:在 https://marketplace.visualstudio.com/VSCode 搜索SFTP, 作者Natizyskunk,下载后,在VSCode中通过 Install from VISX安装
2.SFTP配置
在通过VSCode打开的文件夹下有一个 .vscode的文件夹,在下面新建一个sftp.json,SFTP插件会根据这个json里面的配置做动作
** sftp.json **
[
{
"name": "caevs",
"protocol": "sftp",
"port": 22,
"host": "10.1.1.27",
"username": "dell",
"password": "Admin@123",
"remotePath": "/home/dell/ldq_code/buildsystem/android11/caevs",
"uploadOnSave": true,
"useTempFile": false,
"openSsh": false,
"watcher": {
"files": "**/*",
"autoUpload": true,
"autoDelete": true
},
"ignore": [
"**/.vscode/**",
"**/.git/**",
"**/build/**"
]
}
]
** 参数说明 **
[
{
"name": "caevs",
"protocol": "sftp", //同步文件使用的协议
"port": 22,
"host": "10.1.1.27", //远端服务器IP
"username": "dell", //登录远端服务器的用户名
"password": "Admin@123", //密码
"remotePath": "/home/dell/ldq_code/buildsystem/android11/caevs", //远端服务器路径,上传的文件会以此路径为根目录
"uploadOnSave": true, //保存文件时,自动上传
"useTempFile": false,
"openSsh": false,
"watcher": { //监听files指定目录下的文件
"files": "**/*",
"autoUpload": true, //改变时自动上传
"autoDelete": true //删除时,自动删除远端
},
"ignore": [ //忽略这些目录下的改变
"**/.vscode/**",
"**/.git/**",
"**/build/**"
]
}
]
补充说明
同时配置多个服务器
{
"name": "My Server",
"protocol": "sftp",
"port": 22,
"profiles": {
"android_dell": {
"host": "10.63.1.27",
"username": "dell",
"remotePath": "/home/dell/ldq_code/buildsystem/android11/caevs",
"password": "Admin@123"
},
"android8155": {
"host": "10.63.1.33",
"username": "liuyy",
"remotePath": "/u01/liuyy/Work/LYY/AOSP/8155user/caevs",
"password": "Evs2021!"
}
},
"defaultProfile": "android_dell",
"uploadOnSave": true,
"useTempFile": false,
"openSsh": false,
"ignore": [
".vscode",
".git",
".DS_Store",
"files\external"
],
"watcher": {
"files": "**/*",
"autoUpload": true,
"autoDelete": true
}
}
© 版权声明
文章版权归作者所有,未经允许请勿转载。
相关文章
暂无评论...