{"id":13822856,"url":"https://github.com/andy-5/wslgit","last_synced_at":"2025-05-16T11:07:08.088Z","repository":{"id":38279433,"uuid":"98505208","full_name":"andy-5/wslgit","owner":"andy-5","description":"Use Git installed in Bash on Windows/Windows Subsystem for Linux (WSL) from Windows and Visual Studio Code (VSCode)","archived":false,"fork":false,"pushed_at":"2022-12-30T06:05:02.000Z","size":160,"stargazers_count":1209,"open_issues_count":19,"forks_count":58,"subscribers_count":23,"default_branch":"master","last_synced_at":"2025-04-09T07:02:52.131Z","etag":null,"topics":["bash-on-windows","git","rust","visual-studio-code","vscode","windows-subsystem","windows-subsystem-for-linux","windows-subsystem-linux","wsl","wslgit"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andy-5.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-27T07:10:30.000Z","updated_at":"2025-04-08T09:28:45.000Z","dependencies_parsed_at":"2023-01-31T10:46:06.927Z","dependency_job_id":null,"html_url":"https://github.com/andy-5/wslgit","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-5%2Fwslgit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-5%2Fwslgit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-5%2Fwslgit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andy-5%2Fwslgit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andy-5","download_url":"https://codeload.github.com/andy-5/wslgit/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254518379,"owners_count":22084374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash-on-windows","git","rust","visual-studio-code","vscode","windows-subsystem","windows-subsystem-for-linux","windows-subsystem-linux","wsl","wslgit"],"created_at":"2024-08-04T08:02:21.095Z","updated_at":"2025-05-16T11:07:03.073Z","avatar_url":"https://github.com/andy-5.png","language":"Rust","readme":"# WSLGit\n\nThis project provides a small executable that forwards all arguments\nto `git` running inside Bash on Windows/Windows Subsystem for Linux (WSL).\n\nThe primary reason for this tool is to make the Git plugin in\nVisual Studio Code (VSCode) work with the `git` command installed in WSL.\nFor these two to interoperate, this tool translates paths\nbetween the Windows (`C:\\Foo\\Bar`) and Linux (`/mnt/c/Foo/Bar`)\nrepresentations.\n\n## Installation\n\nThe latest binary release can be downloaded from the\n[releases page](https://github.com/andy-5/wslgit/releases).\n\n**[Optional 1]** Run the `install.bat` script *as administrator*.  \nThe `install.bat` script creates a folder structure similar to the one used by `Git For Windows`, \nand creates some useful symbolic links in the `wslgit\\cmd` and `wslgit\\bin` folders.\n\n**[Optional 2]** Add the `wslgit\\cmd` directory to your Windows `Path`\nenvironment variable (user or system).  \nTo change the environment variable, type\n`Edit environment variables for your account` into Start menu/Windows search\nand use that tool to edit `Path`.\n\nYou may also need to install the latest\n[*Microsoft Visual C++ Redistributable for Visual Studio 2017*](https://aka.ms/vs/15/release/vc_redist.x64.exe).\n\n## WSL distributions and file systems\n\nWhen accessing files on the filesystem in a WSL distribution using the UNC path\n(`\\\\wsl$\\dist\\path` or `\\\\wsl.localhost\\dist\\path`) then the distribution used\nis extracted from the path. This means that git must be setup correctly in all\ndistributions that you intend to access.\n\nWhen accessing files on the Windows filesystem or a mapped network drive the \ndefault WSL distribution is used unless the\n[`WSLGIT_DEFAULT_DIST`](#wslgit_default_dist) environment variable is set.\n\nIf the default WSL distribution is of WSL2 type then it is highly recommended to\nset the `WSLGIT_DEFAULT_DIST` to the name of a WSL1 instance since WSL1 is both\nquicker at accessing the Windows filesystem and can access mapped network drives\nwhich WSL2 cannot.\n\n\u003e Tip: use symlinks to map files and folders in all distributions to a common\n\u003e directory to avoid having to maintain multiple copies, for example you can\n\u003e link the `~/.ssh` folder in all WSL dists to the `.ssh` folder in your Windows\n\u003e home folder.\n\n## Usage in VSCode\n\nVSCode will find the `git` executable automatically if the two optional installation steps were taken.\n\nIf not, set the appropriate path in your VSCode `settings.json`:\n\n```\n{\n    \"git.path\": \"C:\\\\CHANGE\\\\TO\\\\PATH\\\\TO\\\\wslgit\\\\cmd\\\\wslgit.exe\"\n}\n```\n\nAlso make sure that you use an SSH key without password to access your\ngit repositories, or that your SSH key is added to a SSH agent running\nwithin WSL before starting VSCode.\n*You cannot enter your passphrase in VSCode!*\n\nIf you use a SSH agent, make sure that it does not print any text\n(like e.g. *Agent pid 123*) during startup of an interactive bash shell.\nIf there is any additional output when your bash shell starts, the VSCode\nGit plugin cannot correctly parse the output.\n\n\n## Usage from the command line\n\nIf you did the two optional installation steps then \nyou can then just run any git command from a Windows console\nby running `wslgit COMMAND` or `git COMMAND` and it uses the Git version\ninstalled in WSL.\n\n## Usage in Fork\n\nTo make [Fork](https://fork.dev) use `git from WSL` you must have done the first optional installation step (run `install.bat`). Then go to the `Fork` preferences and select a custom git instance where you point it to the `git.exe` in the `wslgit\\bin` folder (**not** the *cmd* folder!).\n\nIf getting an error message about not being able to execute `Fork.RI` then make\nsure that the `Fork.RI` script is executable inside WSL (run `chmod +x Fork.RI`\nif needed).\n\n## Remarks\n\nCurrently, the path translation and shell escaping is very limited,\njust enough to make it work in VSCode.\n\nAll absolute paths are translated, but relative paths are only\ntranslated if they point to existing files or directories.\nOtherwise it would be impossible to detect if an\nargument is a relative path or just some other string.\nVSCode always uses forward slashes for relative paths, so no\ntranslation is necessary in this case.\n\nAdditionally, be careful with special characters interpreted by the shell.\nOnly spaces and newlines in arguments are currently handled.\n\n\n## Advanced Usage\n\n### WSLGIT_USE_INTERACTIVE_SHELL\nTo automatically support the common case where `ssh-agent` or similar tools are \nsetup by `.bashrc` in interactive mode then, per default, `wslgit` executes `git` \ninside the WSL environment through `bash` started in interactive mode for some \ncommands (`clone`, `fetch`, `pull` and `push`), and `bash` started in non-interactive \nmode for all other commands.\n\nThe behavior can be selected by setting an environment variable in Windows \nnamed `WSLGIT_USE_INTERACTIVE_SHELL` to one of the following values:\n* `false` or `0` - Force `wslgit` to **always** start in **_non_-interactive** mode.\n* `true`, `1`, or empty value - Force `wslgit` to **always** start in **interactive** mode.\n* `smart` (default) - Interactive mode for `clone`, `fetch`, `pull`, `push`, \nnon-interactive mode for all other commands. This is the default if the variable is not set.\n\nAlternatively, if `WSLGIT_USE_INTERACTIVE_SHELL` is **not** set but the Windows \nenvironment variable `BASH_ENV` is set to a bash startup script and the environment \nvariable `WSLENV` contains the string `\"BASH_ENV\"`, then `wslgit` assumes that \nthe forced startup script from `BASH_ENV` contains everything you need, and \ntherefore also starts bash in non-interactive mode.\n\nThis feature is only available in Windows 10 builds 17063 and later.\n\n### WSLGIT_DEFAULT_DIST\n\nSet a Windows environment variable called `WSLGIT_DEFAULT_DIST` to the name of a\nWSL distribution to use instead of the WSL default distribution when accessing\nfiles on the Windows filesystem or from mapped network shares.\n\n\u003e Note, to access files on a mapped network drive a WSL1 distribution must be used.\n\n### WSLGIT\n`wslgit` set a variable called `WSLGIT` to `1` and shares it to WSL. This variable can be used in `.bashrc` to \ndetermine if WSL was invoked by `wslgit`, and for example if set then just do the absolute minimum of initialization \nneeded for `git` to function.  \nCombined with `WSLGIT_USE_INTERACTIVE_SHELL=smart` (default) this can make every git command execute with as little overhead as possible.\n\nThis feature is only available in Windows 10 builds 17063 and later.\n\n## Building from source\n\nFirst, install Rust from https://www.rust-lang.org. Rust on Windows also\nrequires Visual Studio or the Visual C++ Build Tools for linking.\n\nThe final executable can then be build by running\n\n```\ncargo build --release\n```\n\ninside the root directory of this project. The resulting binary will\nbe located in `./target/release/`.\n\nTests **must** be run using one test thread because of race conditions when changing environment variables:\n```bash\n# Run all tests\ncargo test -- --test-threads=1\n# Run only unit tests\ncargo test test -- --test-threads=1\n# Run only integration tests\ncargo test integration -- --test-threads=1\n# Run benchmarks (requires nightly toolchain!)\ncargo +nightly bench\n```\n","funding_links":[],"categories":["Rust","WSL Tools","visual-studio-code"],"sub_categories":["10. GUI Apps"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy-5%2Fwslgit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandy-5%2Fwslgit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandy-5%2Fwslgit/lists"}