環境:win7 64位 vscode:1.46.1
問題描述:
使用vscode打開文件夾方式打開項目后,本地文件E:\www\mypro\a.txt 可以上傳到遠程服務器 /Dockerfile/remotepro/a.txt,
但是將此文件夾添加為工作區后,再保存文件自動上傳,文件E:\www\mypro\a.txt 卻上傳到遠程服務器的
/Dockerfile/remotepro/mypro/a.txt。多了一層目錄mypro。
下面可能是我們的一個sftp.json配置內容:
{ "name": "My Server", "host": "47.8.8.34", "protocol": "sftp", "port": 22, "username": "afei", "password": "password", "remotePath": "/Dockerfile/remotepro/", "uploadOnSave": true }
解決:
這時我們需要設置下context配置為當前目錄 mypro 或者 ../mypro 或者 www/mypro 均可以同步成功。
{ "name": "My Server", "host": "47.8.8.34", "protocol": "sftp", "port": 22, "username": "afei", "password": "password", "remotePath": "/Dockerfile/remotepro/", "uploadOnSave": true, "context":"mypro" }
其他配置參見官網:https://github.com/liximomo/vscode-sftp/wiki/config