-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
execute git in WSL for WSL paths #532
base: main
Are you sure you want to change the base?
Conversation
@schummar Thank you for looking into this. I would love for this feature to get merged. |
Thanks for putting this together. I tried to get this working with my local GitHub Desktop but was unsuccessful. The error I'm seeing is "Git could not be found at the expected path" |
You need to use the modified GitHub Desktop version from this PR: desktop/desktop#16378 |
A little script for anyone who wants to try it out: git clone https://github.com/schummar/dugite.git
git clone https://github.com/schummar/desktop.git
cd dugite
git checkout origin/feature/wslGit
yarn
yarn build
yarn link
cd ../desktop
git checkout origin/feature/wslCompatibility
yarn
cd app
yarn link dugite
cd ..
yarn build:prod
|
Thanks @schummar, that helps a lot. I'm still getting errors when running GitHub Desktop though:
It also fails to load any repository from WSL, keeps show "Can't find [repo]" |
Ah my bad. I forgot that you have to link dugite in the app folder as well. I have updated the script. Edit: Actually, only in the app folder. Root was just plain wrong 😬 |
It's working for me, thanks! |
Bumping this PR! WSL-based |
I've been running this since April. I'm too afraid to update to the latest version in case I can't get this feature working again. So I'm sticking with this PR and forgoing updates. |
I've updated the branches once again. You can create a current build if you want. 😉 |
@sergiou87 any chance this can be looked at? cheers |
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.