Skip to main content

Command Palette

Search for a command to run...

Managing Dual GitHub Accounts on a Single Windows Laptop

Published
3 min read
Managing Dual GitHub Accounts on a Single Windows Laptop
A

A Simple Web Developer & Designer

Working with multiple GitHub accounts on a single machine can be confusing, especially when SSH keys, GitHub Desktop and global Git configurations interact. Today, we solved a full dual-account setup scenario for a Windows laptop. Here’s the full documented workflow with example accounts (emails and usernames anonymized).


1. Understanding the Problem

  • Personal account: personal-user (email: personal@example.com)

  • Work account: work-user (email: work@example.com)

  • GitHub Desktop was logged in only with personal account.

  • Git Bash kept prompting to select an account.

  • Multiple SSH keys existed and some paths were misconfigured.

Goals:

  • Personal account should be primary.

  • Work account should also be available.

  • SSH connections should work for both accounts without repeated prompts.

  • GitHub Desktop should respect the correct account per repo.


2. Resetting Git Global Identity

git config --global user.name "personal-user"
git config --global user.email "personal@example.com"
git config --global --list

This ensures all new repositories default to personal account.


3. Generating Separate SSH Keys

Personal Key

ssh-keygen -t ed25519 -C "personal@example.com" -f "/c/Users/username/.ssh/id_ed25519_personal"

Work Key

ssh-keygen -t ed25519 -C "work@example.com" -f "/c/Users/username/.ssh/id_ed25519_work"

4. Configuring SSH Agent

eval "$(ssh-agent -s)"
ssh-add /c/Users/username/.ssh/id_ed25519_personal
ssh-add /c/Users/username/.ssh/id_ed25519_work
ssh-add -l

Check that both keys are listed.


5. Setting Up SSH Config

Create a config file at ~/.ssh/config (no extension):

# Personal account (default)
Host github.com
    HostName github.com
    User git
    IdentityFile /c/Users/username/.ssh/id_ed25519_personal
    IdentitiesOnly yes

# Work account
Host github-work
    HostName github.com
    User git
    IdentityFile /c/Users/username/.ssh/id_ed25519_work
    IdentitiesOnly yes

Important: Use forward slashes and correct /c/Users/... paths for Git Bash.


6. Adding SSH Keys to GitHub

Personal account

  1. Log in to personal-userGitHub SSH Keys

  2. Click New SSH key → title Personal Laptop

  3. Paste /c/Users/username/.ssh/id_ed25519_personal.pub

Work account

  1. Log in to work-userGitHub SSH Keys

  2. Click New SSH key → title Work Laptop

  3. Paste /c/Users/username/.ssh/id_ed25519_work.pub

Remove any old/unused keys to avoid conflicts.


7. Testing SSH Connections

ssh -T git@github.com          # Personal account
ssh -T git@github-work         # Work account

Expected output:

Hi personal-user! You've successfully authenticated...
Hi work-user! You've successfully authenticated...

8. Repository Workflow

Cloning

  • Personal repo:
git clone git@github.com:personal-user/personal-repo.git
  • Work repo:
git clone git@github-work:work-user/work-repo.git

Local Git Identity per Repo

Inside the repo folder:

  • Personal repo:
git config user.name "personal-user"
git config user.email "personal@example.com"
  • Work repo:
git config user.name "work-user"
git config user.email "work@example.com"

Pushing Changes

git add .
git commit -m "Your commit message"
git push origin main

Git automatically selects the correct SSH key based on the host alias.


9. GitHub Desktop Guidelines

  • Keep Desktop logged in with personal account.

  • For work repos, ensure the remote URL uses github-work alias.

  • Desktop respects the remote URL and will use the correct SSH key.

  • Local Git identity ensures commits are attributed correctly.

  • For shared repos, always use SSH alias for the account you’re committing as.

  • Remove old credentials from Windows Credential Manager to avoid HTTPS prompts.


10. Rules

  1. Default identity = personal (global Git + SSH default host).

  2. Work account = use github-work SSH alias + local repo identity.

  3. All shared repositories = always clone/push using the SSH alias of the account you’re committing as.

  4. GitHub Desktop will respect the remote URL; no need to switch Desktop login.

  5. Keep .ssh/config correct, forward-slash paths, and no file extension.

Result: Fully working dual-account GitHub setup on a single Windows laptop, clean, reliable, and avoids prompts.


More from this blog