Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 220
Elie Morin Avatar asked Sep 19 '19 19:09

Elie Morin


People also ask

How do I remove sync changes from VS Code?

If you want to remove all your data from our servers, just turn off sync via Settings Sync is On menu available under Manage gear menu and select the checkbox to clear all cloud data. If you choose to re-enable sync, it will be as if you're signing in for the first time.

What does VS Code Git Sync do?

There is a Synchronize Changes action in the Status Bar, next to the branch indicator, when the current checked out branch has an upstream branch configured. Synchronize Changes will pull remote changes down to your local repository and then push local commits to the upstream branch.

How does VS Code integrate with WSL?

From VS Code You can also access more VS Code WSL options by using the shortcut: CTRL+SHIFT+P in VS Code to bring up the command palette. If you then type WSL you will see a list of the options available, allowing you to reopen the folder in a WSL session, specify which distribution you want to open in, and more.


1 Answers

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

like image 160
Elie Morin Avatar answered Sep 19 '22 14:09

Elie Morin