1. 程式人生 > 實用技巧 >vscode sftp 本地目錄設定問題

vscode sftp 本地目錄設定問題

環境:win7 64位 vscode:1.46.1 問題描述:   使用vscode開啟資料夾方式開啟專案後,本地目錄E:\www\mypro\ 可以上傳到遠端伺服器 /Dockerfile/remotepro/,   但是將此資料夾新增為工作區後,再儲存檔案自動上傳,檔案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" }