When you work on both personal and work projects, it’s common to have separate GitHub accounts.
The challenge? Git often uses the wrong identity when committing, and SSH keys get mixed up.
In this post, I’ll walk you through a clean setup for multiple GitHub accounts on WSL (Windows Subsystem for Linux) using SSH and Git’s conditional config.
Generate SSH Keys for Each Account
Inside WSL, generate one key per GitHub account:
# Personal account
ssh-keygen -t ed25519 -C "personal@email.com" -f ~/.ssh/id_personal
# Work account
ssh-keygen -t ed25519 -C "work@email.com" -f ~/.ssh/id_workAdd each public key (~/.ssh/id_*.pub) to the correct GitHub account under
GitHub → Settings → SSH and GPG keys.
Configure ~/.ssh/config
Tell SSH which key to use for each account:
# GitHub Personal
Host github.com-Personal
HostName github.com
User git
IdentityFile ~/.ssh/id_personal
# GitHub Work
Host github.com-Work
HostName github.com
User git
IdentityFile ~/.ssh/id_workClone Repos Using Aliases
When cloning, use your custom host alias so the right key is picked:
# Personal repo
git clone git@github.com-Personal:username/repo.git
# Work repo
git clone git@github.com-Work:org/repo.gitIf you already cloned a repo with git@github.com:..., just fix the remote:
git remote set-url origin git@github.com-Work:org/repo.gitConfigure Git Identities with Conditional Config
SSH decides which account connects to GitHub.
Now let’s make Git commit with the correct name + email automatically.
Create per-account configs
~/.gitconfig-personal
[user]
name = Personal Name
email = personal@email.com~/.gitconfig-work
[user]
name = Work Name
email = work@email.comUpdate main ~/.gitconfig
# Default (personal)
[user]
name = Personal Name
email = personal@email.com
# Use work identity in ~/work/
[includeIf "gitdir:~/work/"]
path = ~/.gitconfig-work
# Use personal identity in ~/personal/
[includeIf "gitdir:~/personal/"]
path = ~/.gitconfig-personalOrganize Your Projects
Make folders that match your config:
mkdir -p ~/work ~/personal-
Work repos →
~/work/ -
Personal repos →
~/personal/
Now Git automatically picks the correct identity depending on the folder.
Verify
Go inside a repo and check:
git config user.name
git config user.emailCheck SSH identity:
ssh -T git@github.com-Work
ssh -T git@github.com-PersonalBoth should authenticate with the right GitHub account.
Done!
Now you can work seamlessly across multiple GitHub accounts in WSL:
-
Git uses the right commit identity (via conditional config).
-
SSH uses the right account key (via
~/.ssh/config). -
No more accidentally committing work code with your personal email!
👉 Pro tip: if your repos aren’t under ~/work/ or ~/personal/, just update the gitdir: paths in ~/.gitconfig to match your actual directory layout.