I have been using this extension SFTP for some time now. The problem I had for the first time yesterday was this:
When I ran the SFTP:SYNC Remote->Local
command, the files that I had already committed and pushed to my remote Git repository days/weeks/months ago showed up under the Changes section in the Source Control tab in the VSCode left sidebar as if I was doing those changes for the first time.
I never ran the SFTP:SYNC
commands before and totally rely on uploadOnSave:true
setting provided by the extension.
Here is my sftp.json
file:
{
"name": "DEV",
"host": "host",
"protocol": "sftp",
"port": 22,
"username": "username",
"remotePath": "/var/www/html/project-name",
"uploadOnSave": true,
"privateKeyPath": "keypath"
}
Issues:
Its as if Git tracking failed totally. The changes I did in the past are showing up as fresh changes. How to get my previous Git local repository state from yesterday back, if this is a Git issue specifically?
If I discard any changes for the files that showed up as a result of this issue in the Source Control tab, I also lose them in my local repository which I DEFINITELY DO NOT WANT.
Workaround:
I committed the changes in some files (unwillingly) that I was planning to do later this week, so as to avoid losing those changes.
Then, I committed and pushed all the files that showed up as new tracked changes to the remote repository.(Like an overwrite and one big duplicate of all the previous commits to the remote repository).
Then I just pulled the remote repository to the local one. Now, there are no tracked changes and no fresh changes. I would have been at this point later in the week but I had to prepone the whole process.
I would like to avoid using this workaround if I encounter the same situation again in future. Hence, this question here.
Please feel free to ask more information, if required,to solve this issue.