'Git isn't working as expected with vscode remote ssh

I recently tried out vscode's remote SSH feature. It was super easy to setup and connect to a remote server.

I opened the editor to a directory that is a git repo and expected to have the default git features working like normal. But if I edit a file, vscode isn't showing the visual indication that there is a modification in the file. And the git tab doesn't show the change. I can open the terminal in vscode and run git status and I do in fact see the change so I know that's actually editing the file.

If I ssh into the server and run git status I do notice that vscode updates and now shows the change in the git tab. But there's still no visual indication next to the line number in the actual file that is changed.



Solution 1:[1]

Follow the instructions at this link, I've changed the value of fs.inotify.max_user_watches in /etc/sysctl.conf and everything was ok.

Solution 2:[2]

What solved it for me: use the -A option (forward your ssh-agent) when ssh-ing to your remote server. This will allow you to connect to git using your git credentials from the client.

Example:

ssh username@servername -A 

Or just enter

ForwardAgent yes

Into your ssh-config (~/.ssh/config on ubuntu).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 depontimatteo
Solution 2 Simon