Skip to main content

Command Palette

Search for a command to run...

GitHub with Git in WSL (Ubuntu)

Updated
2 min read

To configure GitHub using the WSL terminal in Visual Studio (VS Code), follow these steps. This will allow you to clone, commit, push, and pull repositories using Git from your WSL environment.


✅ Step-by-Step Setup: GitHub with Git in WSL (Ubuntu)

🔹 Step 1: Open WSL Terminal in VS Code

  1. Open VS Code.

  2. Press Ctrl + Shift + P → search “WSL: New Window” → select it.

  3. You are now inside VS Code connected to your WSL terminal (e.g., Ubuntu).


🔹 Step 2: Configure Git in WSL

git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"

You can verify with:

git config --list

🔹 Step 3: Generate SSH Key (if not already done)

ssh-keygen -t ed25519 -C "your-email@example.com"

Press Enter to accept defaults. It generates key pair under ~/.ssh/id_ed25519.


🔹 Step 4: Add SSH Key to GitHub

  1. Display your public key:
cat ~/.ssh/id_ed25519.pub
  1. Copy the output.

  2. Go to GitHub → Settings → SSH and GPG keys

  3. Click New SSH key → paste → save.


🔹 Step 5: Test SSH Connection to GitHub

ssh -T git@github.com

If successful, you’ll see:

Hi your-username! You've successfully authenticated...

🔹 Step 6: Clone a Repo Using SSH

git clone git@github.com:your-username/your-repo.git
cd your-repo
code .

This opens the repo in VS Code WSL and you're ready to code!


✅ Common Git Commands (WSL)

git status
git add .
git commit -m "your message"
git push origin main
git pull origin main

🔧 Tip: Set VS Code as Default Git Editor in WSL (optional)

git config --global core.editor "code --wait"