GitHub Desktop in Windows Subsystem for Linux (WSL2)

Mrudul John Mathews
5 min readJun 10, 2024

--

Greetings Developer Community šŸ‘‹,
Itā€™s been a long time since Iā€™ve written something, so pardon my language pleasešŸ˜…. I wanted to pen down this coz I couldnā€™t properly find a tutorial or video on ā€œHow to integrate GitHub Desktop App with Windows Subsystem for Linux (WSL2)?ā€ anywhere on the web. So guys, without further ado, letā€™s get to it.

What is GitHub Desktop?

GitHub Desktop is a desktop client for GitHub (yeah, the definition was a bit shorter than I expected). For developers who arenā€™t comfortable with GitHub shell commands and for experienced developers who want to ease complex Git operations (resolving conflicts, cherry-picking, complex merges, etc.), GitHub Desktop is here to save the day. Itā€™s officially available for Windows and macOS (and yes, there are some tricks to install it on Linux distros too!). If you havenā€™t tried it yet, head over to GitHub Desktop and see if itā€™s your cup of tea.

What is Windows Subsystem for Linux?

Official Definition: Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine without the need for a separate virtual machine or dual-booting. WSL is designed to provide a seamless and productive experience for developers who want to use both Windows and Linux at the same time.
Key Features:

  • Install and run various Linux distributions, such as Ubuntu, Debian, Kali, and more.
  • Store files in an isolated Linux file system, specific to the installed distribution.
  • Run command-line tools, such as BASH
  • Invoke Windows applications using a Unix-like command-line shell.
  • Invoke GNU/Linux applications on Windows.
  • And much moreā€¦

What is WSL 2?

Official Definition: WSL 2 is the default distro type when installing a Linux distribution. WSL 2 uses virtualization technology to run a Linux kernel inside a lightweight utility virtual machine (VM). Linux distributions run as isolated containers inside the WSL 2 managed VM. WSL 2 increases file system performance and adds full system call compatibility compared to the WSL 1 architecture. Check this out to learn more about how WSL 1 and WSL 2 compare .

In simple words, WSL2 is an advanced version of WSL with better performance and compatibility.

Why Integrate GitHub Desktop with WSL2?

Letā€™s take the case of a RubyšŸ’ŽDeveloper (boasting my own story here šŸ˜). Itā€™s complicated to install Ruby or the Rails framework on Windows OS, leading to dozens of bugs and errors as your project grows. Even the official documentation suggests using WSL for installing Ruby. I have already installed GitHub Desktop on Windows and have been using it for a while. However, GitHub Desktop cannot directly access WSL, meaning it cannot clone a repo or execute Git commands for a project (like my Ruby on Rails project) stored in the Linux subsystem. What if I want to use GitHub Desktop to merge a branch for my Rails project? This is where the need for integration between GitHub Desktop and WSL comes into play.

How to Integrate WSL and GitHub Desktop

Assuming you already have WSL2 installed and running:

1. Download and install GitHub Desktop App:

  • Visit GitHub Desktop and follow the instructions to install it.
GitHub Desktop

2. Log in with your GitHub account:

  • Open GitHub Desktop and sign in using your GitHub credentials.
Sign in to your GitHub Account

3. Open Explorer and click on the Linux icon:

  • Navigate to your WSL file system via the Linux icon in Windows Explorer.
Open the Linux File System
Navigate to your project directory
  • Navigate to your project directory in WSL file system (Here , \Ubuntu-22.04\home\mrudul\code\rails) and Copy the Path. The path would look something like this : (e.g., \\wsl.localhost\Ubuntu\home\username\projectfolder\)
Copy the Path

4.Configure GitHub Desktop with your WSL directory:

To clone a new repo into your Linux subsystem:

  • In GitHub Desktop, select ā€œFile -> Clone a repositoryā€
Clone Repository
  • Paste the copied path in the Local Path(e.g., \\wsl.localhost\Ubuntu-22.04\home\mrudul\code\rails\test\walkthrough_awanllm_gem). Add the link of the Repository you want to clone in Repository URL field.
Paste linux folder path for cloning repo
  • Select the ā€˜Cloneā€™ button to clone your favorite repository to your Linux Subsystem with GitHub Desktop integrated.

To initialize a local development folder (in the Linux subsystem) as a Git repo:

  • Select ā€œFile -> New Repositoryā€ in GitHub Desktop.
New Repository
  • Paste the Local path to your existing project folder (e.g.,\\wsl.localhost\Ubuntu-22.04\home\mrudul\code\rails\test\prjct).
Paste Exisiting project path to initialize new repo

To configure GitHub Desktop for an already git-initialized repo in the Linux subsystem:

  • Choose ā€œAdd an existing repositoryā€ in GitHub Desktop.
Add Local Repository
  • Paste the Local path to your existing repo stored in Linux Subsystem (e.g.,\\wsl.localhost\Ubuntu-22.04\home\mrudul\code\rails\first-project\firstapp).
Adding trust exception to project directory
  • If you get an error like ā€œ The Git repository appears to be owned by another user on your machine. Adding untrusted repositories may automatically execute files in the repository.ā€ , click ā€œadd an exception for this directoryā€ to remove this warning and finish with ā€œAdd Repositoryā€ button.

5. No more steps needed šŸ˜‰ You have successfully configured GitHub Desktop for your project from the Linux subsystem.

By following these steps, you can seamlessly integrate GitHub Desktop with WSL2, enabling a smoother workflow for your development projects.

Thank you for reading! If you found this guide helpful, please share it with others who might benefit from it. Happy codingā¤ļø!

--

--

Mrudul John Mathews

Python-Ruby Dev | JAPAN Intern '24 | UI/UX Designer | Top 100 Coder Fellow '23 | Competitions Coordinator IEEE LINK | Co-Founder Charge IT