Skip to content

WSL compatibility#16378

Open
schummar wants to merge 12 commits intodesktop:developmentfrom
schummar:feature/wslCompatibility
Open

WSL compatibility#16378
schummar wants to merge 12 commits intodesktop:developmentfrom
schummar:feature/wslCompatibility

Conversation

@schummar
Copy link
Copy Markdown

Together with desktop/dugite#532, this potentially closes

Description

Depends on desktop/dugite#532. Together this will introduce compatibility with WSL. While you can just open a repository in WSL by entering its UNC path, this never worked right for me and many others. It suffers from

  • Bad performance
  • Checking out with wrong line endings (I know, can be configured, but it doesn't just work™)
  • Wrongly detected changes
  • Git hooks don't work

My suggestion to solve all this simple: Run git within WSL wsl.exe -e git .... The most important part is contained in the Dugite pull request. Assuming that gets merged, this PR fixes a few edge cases connected to it and improves WSL compatibility in regards to external editors and shells by

  • fixing discarding files when no trash is available
  • adding an option to open WSL repositories in Vs Code Remote directly
  • adding an option to open WSL repositories in WSL shell, even if another shell is selected for other repos

There are certainly some things to be discussed and edge cases to be fixed. I'm happy to make adjustments based on your feedback and hope that you can see the advantage of taking this route.

Screenshots

image

Release notes

@niik
Copy link
Copy Markdown
Member

niik commented Apr 3, 2023

Hey @schummar, thanks for wanting to contribute! I wanted to set some expectations here that we will have to have a thorough discussion internally before we can provide any feedback here and that might take a while. GitHub Desktop ships with a specific custom built version of Git because we have to be able to rely on specific features being present, localization being turned off, and specific formats of Git output that could (and do) change between versions etc. Outsourcing that to a Git version we don't have control over would be fragile at best and poses other questions around ensuring compatible versions of Git LFS being installed etc. We would likely want to run a specific dugite version within the WSL environment.

I certainly empathize with the friction you're encountering running Desktop alongside a WSL environment and it's clear that you've done a thorough job of going through the codebase to create a comprehensive solution but I want to set reasonable expectations that we won't have a lot of time to get into reviewing and considering this work in the short term.

@schummar
Copy link
Copy Markdown
Author

schummar commented Apr 3, 2023

@niik thanks for the reply. I didn't expect this to be quick. Of course this is a big decision and will take time, no worries.

I made the Pull Request also as a POC. The existing discussions regarding WSL were mostly "use UNC paths, it's working fine" and some tweaks and workarounds to make it somewhat workable. But that approach is fundamentally flawed and another idea is needed. I wanted to show that running git withing WSL might be such an idea. WSL is such a big deal for developers using Windows, so it deserves first class support in tools. 😉

Your point about using a specific git version makes sense. I see no issue with using an embedded git version also for WSL as well. I'll try to include this in the Dugite PR.

Whenever you had time to discuss it and if you decide that the solution has potential, I'll be happy to work with you to iron out the problems and make it production ready.

@schummar
Copy link
Copy Markdown
Author

schummar commented Apr 3, 2023

Your point about using a specific git version makes sense. I see no issue with using an embedded git version also for WSL as well. I'll try to include this in the Dugite PR.

I have updated the Dugite PR

@schummar
Copy link
Copy Markdown
Author

schummar commented Apr 26, 2023

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

@SynthLuvr
Copy link
Copy Markdown

I can't comment on the code because I'm unfamiliar with this repository, but I've been testing this and the user experience is vastly improved. Everything is working smoothly so far.

@SynthLuvr
Copy link
Copy Markdown

SynthLuvr commented May 10, 2023

I've encountered a problem where an error is caused triggering a pre-commit hook:

resources/app/git/linux-x64/libexec/git-core/git', 'fetch', 'origin', '--tags')
return code: 128
stdout: (none)
stderr:
    git: 'remote-https' is not a git command. See 'git --help'.
    
    The most similar command is
	    remote-http

Edit: This is an edge case where GitHub Desktop errors on the first commit installing git hooks. After committing using git in the terminal, the hooks get set up properly and then GitHub Desktop works correctly for subsequent commits.

@schummar
Copy link
Copy Markdown
Author

It seems that problem has been discussed a lot already in other issues quite a bit, so it's probably not connected to the WSL integration. See #10345 (comment).

But if you can provide a repo that demonstrates the issue, I will have a look.

@spankandex
Copy link
Copy Markdown

what do we need to have this in the master branch? it's impossible to use github for desktop with a repo in WSL

@SynthLuvr
Copy link
Copy Markdown

I've been using this branch. I do not use the main branch. Getting this merged into main branch is ideal so I can continue to get regular updates.

@schummar
Copy link
Copy Markdown
Author

schummar commented Jul 8, 2023

what do we need to have this in the master branch? it's impossible to use github for desktop with a repo in WSL

I am currently waiting for feedback from the team. As @niik said, it can take some time. Maybe he can provide an update some time ;-)

Btw. I merge the latest main/development branches from time to time, but be aware that using a build from this branch might be outdated and auto update can't work either.

@thesyntaxinator
Copy link
Copy Markdown

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

Should this be run in WSL or windows terminal?

@schummar
Copy link
Copy Markdown
Author

In Windows Terminal.

@sarim
Copy link
Copy Markdown

sarim commented Jul 28, 2023

I haven't looked at the details of this PR, but a good implementation for similar thing is to look at vscode. Actual vscode logic remains with vscode-server, and it's can run in any remote machine. Vscode is just the UI user interacts with. Github desktop could adopt a similar architure. Though realistically its seems kinda unfeasible considering desktop's team size / target audience.

I've been using the shiftkey/desktop fork in wsl from the start of wsl2. It is my daily driver for software development. Needed some minor issue solving from time to time, but overall it just works. Especially after introduction of WSLg, using linux version of desktop just feels more realistic.

@thesyntaxinator
Copy link
Copy Markdown

In Windows Terminal.

How do I add a repository located on WSL? I'm unable to see WSL directories in the folder selector that pops up when I click "Browse".

@schummar
Copy link
Copy Markdown
Author

I haven't looked at the details of this PR, but a good implementation for similar thing is to look at vscode. Actual vscode logic remains with vscode-server, and it's can run in any remote machine. Vscode is just the UI user interacts with. Github desktop could adopt a similar architure. Though realistically its seems kinda unfeasible considering desktop's team size / target audience.

Yes, that would be a valid approach too. But a lot more effort, which is probably not needed for this use case.

I've been using the shiftkey/desktop fork in wsl from the start of wsl2. It is my daily driver for software development. Needed some minor issue solving from time to time, but overall it just works. Especially after introduction of WSLg, using linux version of desktop just feels more realistic.

That works generally, but I think the user experience is not optimal. WSLg windows are not as performant and seamless as native windows and if you work both on the Windows side and in WSL, you'd have to have the app installed twice.

@schummar
Copy link
Copy Markdown
Author

In Windows Terminal.

How do I add a repository located on WSL? I'm unable to see WSL directories in the folder selector that pops up when I click "Browse".

Showing the WSL drives in Explorer has been working occasionally for me, but it's indeed very flaky. What should always work is to put the path directly into the file picker's url. E.g. \\wsl.localhost\Ubuntu where "Ubuntu" is the name of your WSL instance.

@omzy
Copy link
Copy Markdown

omzy commented Dec 6, 2023

Is there any update on this? I'm using GitHub Desktop with a WSL mounted drive and every operation is way too slow, compared to non-WSL mounted drives.

@TomasSlama
Copy link
Copy Markdown

Hey @schummar 👋, thank you for your effort on this. I'm trying it out locally and I have this error
image

Do you have any suggestions on what could be wrong on my side? 🤔

@schummar
Copy link
Copy Markdown
Author

schummar commented Jun 3, 2024

Do you have any suggestions on what could be wrong on my side? 🤔

You also have to use the modified version of dugite. See my comment: #16378 (comment)

@TomasSlama
Copy link
Copy Markdown

Hey @schummar I removed everything and started over and I still have an issue

image

it happens when I select any repository inside WSL2

@schummar
Copy link
Copy Markdown
Author

schummar commented Jul 3, 2024

You can open devtools with Ctrl+Shift+I or under View -> >Toggle developer tools. Is there more information about the error?

@TomasSlama
Copy link
Copy Markdown

I found this #17362 and followed the instructions to remove all local files from the original installation.

After that I'm not able to login with Github account, for some reason it ends up on this page for ever, the link is doing nothing.
image

So I decided to skip the login, but still the application can't see the repositories on WSL for me. Those are the errors in console:

image

@schummar
Copy link
Copy Markdown
Author

schummar commented Jul 3, 2024

Are you running GitHub Desktop from within WSL? It's not meant to be used like this. The idea behind the PR is, that you run the application in Windows and access WSL folders from there. If you want to run it in WSL directly, you can try this fork that is meant be run in Linux environments: https://github.com/shiftkey/desktop

If that is not the case, can you enable "All levels" in the console? Maybe there are more hints about where it's going wrong there.

@TomasSlama
Copy link
Copy Markdown

No other information when all levels set. Yeah I run it from the Windows. But all other developing-related things I have in WSL, so maybe I'm missing some library or something, but I have no idea what.

I guess you don't need to waste energy on this issue, I needed GUI only from time to time, when I worked with too many updated files, as I had the need today again and just bought GitKraken for one year. Hopefully, GitHub will integrate your solution till then ;-)

@0963493816
Copy link
Copy Markdown

0963493816 commented Jul 3, 2024 via email

@SynthLuvr
Copy link
Copy Markdown

I've been using this branch. I do not use the main branch. Getting this merged into main branch is ideal so I can continue to get regular updates.

I tried the latest update and it's not working (no ability to add repos via UI), so I reverted to the previous commit

@steveward steveward added the external Pull request originating outside of the Desktop core team label Oct 4, 2024
@tidy-dev tidy-dev added triage For incoming issues and removed triage For incoming issues labels Mar 11, 2025
@MiloudiMohamed
Copy link
Copy Markdown

Thank you so much for this. I've just installed it and it's working perfectly.

I find it very strange that the PR is already +2 years and almost every WSL user is reporting performance issues without receiving any response, meanwhile, the focus mostly seems to be on UI adjustments.

By the way, I wonder if this branch can be updated to latest changes in main or it will stuck in the current version

@MiloudiMohamed
Copy link
Copy Markdown

For anyone trying to use GitHub Desktop with WSL and tired of years of painful slowness, this is the solution.

https://github.com/MiloudiMohamed/wsl-git-bridge

@SynthLuvr
Copy link
Copy Markdown

For anyone trying to use GitHub Desktop with WSL and tired of years of painful slowness, this is the solution.

https://github.com/MiloudiMohamed/wsl-git-bridge

Get error when loading GitHub Desktop with git.exe replaced:
image

@MiloudiMohamed
Copy link
Copy Markdown

@SynthLuvr can you tell what version you are using? and what Linux distro ? it's now hardcoded to Ubuntu (will do fix it later)

Please reply here, I've created an issue in the repo itself

@kittenchilly
Copy link
Copy Markdown

For anyone trying to use GitHub Desktop with WSL and tired of years of painful slowness, this is the solution.

https://github.com/MiloudiMohamed/wsl-git-bridge

Does this also stay fast when on a repo thats on windows side? I have some repos on linux and some repos on windows.

@MiloudiMohamed
Copy link
Copy Markdown

@kittenchilly I've just tested it, and yes, it should be as fast as normal

@omzy
Copy link
Copy Markdown

omzy commented Feb 5, 2026

For anyone trying to use GitHub Desktop with WSL and tired of years of painful slowness, this is the solution.

https://github.com/MiloudiMohamed/wsl-git-bridge

Thanks, I will try this soon. Just a quick question - will this replacement git.exe work with local (i.e. non-WSL) repos too?

@FoxtrotSierra6829
Copy link
Copy Markdown

FoxtrotSierra6829 commented Feb 5, 2026

For anyone trying to use GitHub Desktop with WSL and tired of years of painful slowness, this is the solution.
https://github.com/MiloudiMohamed/wsl-git-bridge

Thanks, I will try this soon. Just a quick question - will this replacement git.exe work with local (i.e. non-WSL) repos too?

@omzy Read the two comments above yours

@MiloudiMohamed
Copy link
Copy Markdown

@omzy Yes it does work, no problem

@omzy
Copy link
Copy Markdown

omzy commented Feb 5, 2026

@omzy Yes it does work, no problem

OK thanks. It didn't work for (I got the exit code 1 error). I can see above you said it's only built for Ubuntu - my distro is RHEL 8 - do you have any plans to support that?

@MiloudiMohamed
Copy link
Copy Markdown

@omzy Sure very soon, can you paste the error logs (Help > Show logs in Explorer) here MiloudiMohamed/wsl-git-bridge#1 or create a new issue

@aleixrodriala
Copy link
Copy Markdown

aleixrodriala commented Mar 26, 2026

I've been struggling with this for a while and ended up building a fork that fixes it: GithubDesktopWSL

Think of it like the VS Code Remote WSL extension but for GitHub Desktop. It runs a small daemon inside WSL that handles git and file operations natively over TCP instead of going through 9P.

Operation Fork Official Speedup
git status 2 ms 43 ms 20x
git log 2 ms 41 ms 24x
Open repo 16 ms 173 ms 11x

I went with a patch-based approach so it auto-syncs with upstream releases. You can just download the installer and try it, installs side-by-side with official Desktop.

Would love if anyone here could give it a try and let me know how it goes!

@SynthLuvr
Copy link
Copy Markdown

@aleixrodriala a fork is going to be harder to maintain. What's the advantage over using https://github.com/MiloudiMohamed/wsl-git-bridge ? So far this works very well

@aleixrodriala
Copy link
Copy Markdown

aleixrodriala commented Mar 26, 2026

@aleixrodriala a fork is going to be harder to maintain. What's the advantage over using https://github.com/MiloudiMohamed/wsl-git-bridge ? So far this works very well

Git-bridge spawns wsl.exe per command and adds 93mson each op, file operations like diffs, merge state and .gitignore still go through 9P with a git-only shim, and Desktop overwrites its bundled git.exe on every update, so you need to patch it every update.

So basically native support for all WSL actions and automatic updates is what you get.

I have also updated the README with a "Why a daemon and not a shim" section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external Pull request originating outside of the Desktop core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.