VSCode: use WSL Git instead of Git for Windows

I created a small tool to solve this for myself, and hosted it on GitHub.

Basic git functionality seems to work, like viewing changes and committing.

A ready-to-use binary can be downloaded from the Releases page.

One of the problems is that the input paths need to be translated from the Windows representation (C:\Foo\Bar) to the Linux paths in WSL (/mnt/c/Foo/Bar), and back again for paths in the output of git.

For example, the Git plugin in VSCode uses the command

git rev-parse --show-toplevel

to find the root directory of the git repository, but with WSL git this of course returns a Linux path that needs to be translated for VSCode on Windows.


Provide the full path for the bash exec :

git.bat :

@echo off
c:\windows\sysnative\bash.exe -c "git %*"

Since VS Code 1.34 (April 2019) a remote extension has been introduced to develop into WSL: https://code.visualstudio.com/docs/remote/wsl.

Basically, a server instance of VS Code is started into WSL, allowing you to use all the WSL tools (e.g. git) from your client instance on Windows.

Thank you for pointing that out @Noornashriq Masnon!


What you can do is to first try wslpath and if that fails you try a normal git command. It's not ideal but it works.

See: Use WSL git inside VS Code from Windows 10 17046