VSCode: Use WSL Git instead of Git for Windows

I would like to use WSL (Bash for Windows) Git with VSCode instead of Git for Windows to avoid multiple Git installations.

I created a simple bat script to emulate git.exeby redirecting Git commands to WSL. It works fine in CMD, but not with VSCode. In addition, WSL is my default terminal in VSCode.

VSCode settings.json :

{
    "git.path": "D:\\tools\\git.bat",
    "terminal.integrated.shell.windows": "C:\\Windows\\Sysnative\\bash.exe"
}

and git.bat :

@echo off
bash -c 'git %*'

Any idea to get VSCode to work with WSL Git?

+6
source share
2 answers

, GitHub.

git , .

.

, Windows (C:\Foo\Bar) Linux WSL (/mnt/c/Foo/Bar) git.

, git VSCode

git rev-parse --show-toplevel

git, WSL git , , Linux, VSCode Windows.

+6

bash exec:

git.bat:

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

All Articles