Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Executing git commands from Windows on WSL (Windows Subsystem for Linux) paths has some problems. The major ones (that I'm aware of) are
My use case is, I would like to use GitHub Desktop to manage my git repos both in windows and in WSL, where I do most of my programming. Commonly recommended solutions like running GitHub Desktop in WSL (WSL GUIs are not stable enough for my tastes) or just opening the WSL path in GitHub Desktop on Windows (suffers from the above mentioned issues) are not working for me.
There are a number of issues that are related to this, e.g. desktop/desktop#13953
Solution
So my suggestion is this: When working in repositories that have a WSL path (e.g.
\\wsl$\home\user\src\whatever
or\\wsl.localhost\\Ubuntu\home\user\src\whatever
), execute git commands within WSL:wsl.exe -e git ...
. This PR is a POC and probably needs more work, so I am grateful for any feedback. It works very smoothly in my locally built GitHub Desktop though.My considerations so far:
Performance
The approach works a lot faster on my machine. I can't say I have done bullet proof benchmarking yet, but some of my tests show significant improvements:
Opening a repository - old:
Opening a repository - new:
Checking out a branch - old:
Checking out a branch - new:
Authentication
WSL has a neat mechanism to forward environment variables between WSL and Windows processes. It even can convert paths while doing it. By forwarding certain env vars, authentication seem to work nicely for private repositories.
Multiple WSL distributions
Since the distribution name is part of the WLS repo path, it can be specified in the command, so working across multiple distributions should work, though I didn't test that case yet.