Search code examples
gitvisual-studio-codewindows-subsystem-for-linux

VSCode + WSL Remote + Git : Synchronizing changes take forever


I'm using VSCode remotly into my project folder located (symlink) into WSL 2 VM. I cloned my repo from Bitbucket using SSH and the terminal.

On the bottom left corner, it indicate WSL: Ubuntu, so I'm currently using it remotly. ALL GOOD
If I click the Git branch indicator, I can see local branchs and remote one. ALL GOOD

The problem is that when I click to synchronize everything after a local commit, it spins forever. Well, not really, I lose patience before forever happen... Currently about 30 minutes on the current test.

If I do git push into the terminal, everything goes as expected.

Any one got an idea on why it's doing this? How can I solve that problem?

My Git output into VSCode constantly return this git rev-parse --show-toplevel?
I did git config for both user.name and user.email
SSH key is set on Bitbucket. Windows and WSL 2 are using the same public/private key.

Thank you


Solution

  • 2021-02-05 UPDATE

    This question got a lot of views recently and I felt like I needed to give a more thorough explanation. The original answer was written when WSL 2 was still in beta for testing purposes. Now that everything has evolved, removing the passphrase from an SSH-Key can lead to some vulnerabilities. So, before going any further with this, take a look at this post Is it okay to use a SSH key with an empty passphrase?

    Ask yourself if it safe for you to remove it.

    I don't know if there is still an issue with the orignal question. I gave up on WSL for web dev shortly after I wrote the question.

    ORIGINAL ANWSER

    I solved my issue. So, for thoses of you that want to give WSL 2 a try and encounter this, the issue is the passphrase of the SSH-key.

    https://code.visualstudio.com/docs/remote/troubleshooting#_resolving-hangs-when-doing-a-git-push-or-sync-on-an-ssh-host

    Resolving hangs when doing a Git push or sync on an SSH host
    If you clone a Git repository using SSH and your SSH key has a passphrase, VS Code's pull and sync features may hang when running remotely.

    Either use an SSH key without a passphrase, clone using HTTPS, or run git push from the command line to work around the issue.

    If you want to remove your passphrase, use $ ssh-keygen -p as mentioned into this question: https://stackoverflow.com/a/112409/5543999