These scripts allow you to proxy commands (specifically git
, in this example) to the Windows Subsystem for Linux from the normal Windows command line environment. This allows you to work with a single installation of git (under your Linux distribution) instead of trying to manage two concurrent installations.
I explicitly created these scripts to allow using Git in Visual Studio Code without installing it under Windows.
Please note that I have not extensively tested edge cases! If you run into problems, please let me know!
- Install the scripts somewhere on your normal Windows drive; e.g.
C:\Users\USERNAME\dev\proxy_scripts
. - In VSC, modify your
settings.json
file and add thegit.path
setting pointing to yourgit.bat
file; e.g."git.path": "c:\\Users\\USERNAME\\dev\\proxy_scripts\\git.bat"
- Enjoy WSL git from the VSC GUI! (You might need to relaunch the app.)
If you want to proxy further commands, you can do so by duplicating git.bat
and changing the command that is getting invoked (so replace git
on line 6 with whatever command you want to proxy). Presumably, you could also add these scripts to your Windows PATH if you wanted to go the extra mile, though I'm not sure how that would interact with the WSL bash.exe
environment (could end up round-tripping everything uselessly, if your Windows binary locations occur earlier in the PATH than the WSL ones).
Please enjoy responsibly!
wsl-alias
offered a fantastic starting point for this approach and is a nifty project all around: https://github.com/leongrdic/wsl-aliaswsl-proxy
gave me the initial inspiration for writing simple proxy batch files: https://github.com/watzon/wsl-proxy
Thank you for the script, it does seem to work from within an ordinary Command Prompt in Windows, so thank you already for that.
However, I cannot seem to get VSCode to be aware of it. :( Using VSCode 1.93.1, I tried to configure the User setting
"git.path"
to refer to the"git.bat"
location, or to its folder (I even tried both "/" as well as "\\" in the path) etc. but it kept failing: VSCode kept complaining that it does not recognize any Git installation. :(Any ideas?
(p.s. I tried, using the WSL extension, to start VS Code either from Windows and run the command "WSL: Connect to WSL", or - hopefully equivalently - execute the command
code .
from inside the Ubuntu shell in the project directory after Icd
-ed into it from the Ubuntu shell. In both cases, VSCode would run in the context of WSL and thanks to its WSL extension it would have access to WSL'sgit
, without needing that cool .bat scripts. This seemed to work at a first glance. However, when I modified a file, it wasn't marked as modified in the Explorer pane in VSCode automatically, but I had to press the 'Refresh' button from inside the Source Control pane, which is an unacceptable workflow. So... bottom line: thank you for your scripts, but I gave up and eventually installed Git for Windows)