GitHub with Git in WSL (Ubuntu)
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
Open VS Code.
Press
Ctrl + Shift + P→ search “WSL: New Window” → select it.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
- Display your public key:
cat ~/.ssh/id_ed25519.pub
Copy the output.
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"