Use Git installed in WSL(windows Subsystem for Linux) from Windows and Visual Studio Code.
The project was inspired by A. R. S.'s project andy-5/wslgit written by Rust.
But why do I re-implement it by scripts, because I hope the wslgit tools could support any mount points (but not only under the /mnt/
) and could be used without compiling.
- Please ensure
git
is installed in your WSL. - Copy
wslgit.sh
to the/usr/bin/
or~/bin
directory in your WSL. - Add the following config into your VSCode Settings.
{ "git.path": "C:\\path\\to\\git.bat" }
wslgit launch git installed in WSL in interactive shell mode by default now.
In short, the ssh-agent
setup in .bashrc
script is supported. but slower then non-interactive mode.
If you want disable interactive shell to reduce launch time, you can set Windows environment variable WSLGIT_USE_INTERACTIVE_SHELL
to false
.
[System.Environment]::SetEnvironmentVariable("WSLGIT_USE_INTERACTIVE_SHELL", "false", "User")
- Fixed bug caused by Windows 10 19H1 changed the output of
mount
command
- BREAKING CHANGE: Start git installed in WSL in interactive mode.
- If you want to use non-interactive mode, just like before: Set Windows env variable
WSLGIT_USE_INTERACTIVE_SHELL
totrue
.
- If you want to use non-interactive mode, just like before: Set Windows env variable
- Fixed error in the unix path to win path convert function.
- Related issue: #11 (Thanks @rennex)
- Added path converting for the output of
git init
- Pass all arguments and env variable
WSLGIT_SH_CWD
intowslgit.sh
in WSL when you or VSCode executegit.bat
. - Get all mounted drive info by
mount -t drvfs
command inwslgit.sh
. - Move cwd(current working directory) to
WSLGIT_SH_CWD
. - Iterate arguments, and replace each path argument from Windows style to Linux style by reference to mounted drive info.
- And convert the path in the git output to Windows style if git arguments included special keywords/actions. (Eg.
rev-parse
,remote
) - Why the it doesn't use
wslpath
for path convert, please reference to the test case: test-win/main.js
- Automatic test on Linux (also WSL): test-ci/main.sh
- Semi-automated test on Windows: CONTRIBUTING.md