DEV Community

Abhishek Mishra
Abhishek Mishra

Posted on

Managing Multiple GitHub Accounts & Branches on Windows

Ever feel like your Windows machine is hosting a GitHub account meetup—your personal projects in one corner, work repos in another—and you’re stuck with the wrong name tag? Fear not. In this post, I’ll show you how to juggle multiple GitHub accounts and keep your branches as organized as your desktop icons (well, almost). Expect a few laughs, zero hair-pulling, and a workflow that actually scales on Windows.


Table of Contents

  1. The Windows SSH Setup: Keys & Pageant or OpenSSH
  2. Git Config: Who Am I Today?
  3. Branching Like a Boss
  4. Switching Contexts Without Facepalms
  5. Windows‑Specific Pro Tips & Pitfalls
  6. Wrap-Up: Your Workflow, Upgraded

1. The Windows SSH Setup: Keys & Pageant or OpenSSH

Goal: One Windows PC, two (or more) GitHub personae, zero confusion.

A. Generating Separate SSH Keys in Git Bash

Open Git Bash (or your preferred shell):

# Personal key
ssh-keygen -t ed25519 -C "you.personal@example.com" -f ~/.ssh/id_ed25519_personal

# Work key
ssh-keygen -t ed25519 -C "you.work@company.com" -f ~/.ssh/id_ed25519_work
Enter fullscreen mode Exit fullscreen mode

Tip: When prompted for a passphrase, choose something strong—but memorable (so you’re not retyping it every hour).

B. Using Windows OpenSSH Agent

Windows 10/11 includes an OpenSSH agent you can enable:

  1. Search Services in the Start menu, find OpenSSH Authentication Agent, and set it to Automatic then Start it.
  2. In PowerShell or Git Bash:
   # Add your keys
   ssh-add ~/.ssh/id_ed25519_personal
   ssh-add ~/.ssh/id_ed25519_work
Enter fullscreen mode Exit fullscreen mode

C. (Alternative) Using PuTTY & Pageant

If you prefer PuTTY:

  1. Use PuTTYgen to load id_ed25519_personal and id_ed25519_work, saving them as .ppk.
  2. Launch Pageant, add both .ppk files.
  3. In your PuTTY/SuperPuTTY config, point to the correct key for each host.

D. Configure SSH Hosts

Edit (or create) C:\Users\<YourUser>\.ssh\config:

# Personal GitHub
Host github-personal
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_personal

# Work GitHub
Host github-work
  HostName github.com
  User git
  IdentityFile ~/.ssh/id_ed25519_work
Enter fullscreen mode Exit fullscreen mode

When cloning or setting remotes, use:

git clone git@github-personal:you/my-blog.git
git clone git@github-work:company/project.git
Enter fullscreen mode Exit fullscreen mode

2. Git Config: Who Am I Today?

Git needs your name & email per repo. Don’t let it guess.

  • Global Defaults
  git config --global user.name "Your Name"
  git config --global user.email "you.personal@example.com"
Enter fullscreen mode Exit fullscreen mode
  • Per‑Repo Overrides
  cd C:/path/to/work/project
  git config user.name "Your Work Alias"
  git config user.email "you.work@company.com"
Enter fullscreen mode Exit fullscreen mode

Now commits in that folder will use your work identity.


3. Branching Like a Boss

Keep branches clear. Adopt a naming template:

<type>/<ticket#>-<short-desc>
Enter fullscreen mode Exit fullscreen mode
  • Types: feat, fix, chore, docs
  • Example: feat/42-add-search-box
git checkout -b feat/42-add-search-box
Enter fullscreen mode Exit fullscreen mode

Benefits:

  • Readability: Know at a glance what each branch does.
  • Isolation: One feature, one branch—no accidental cross-contamination.

4. Switching Contexts Without Facepalms

On Windows, context switching can be a breeze:

  1. PowerShell Aliases (add to your Microsoft.PowerShell_profile.ps1):
   Set-Alias gpsh 'git push git@github-personal'
   Set-Alias gwsh 'git push git@github-work'
Enter fullscreen mode Exit fullscreen mode
  1. Windows Terminal Profiles: Create separate profiles for personal vs. work, each initializing SSH agent with the correct keys.
  2. Verify Before You Push
   git remote -v
Enter fullscreen mode Exit fullscreen mode

Always check your remote URL to avoid pushing to the wrong account.


5. Windows‑Specific Pro Tips & Pitfalls

  • Long Path Issues: Enable long paths in Windows 10+ via Group Policy or registry—avoids “Filename too long” errors.
  • CRLF vs. LF: Keep .gitattributes in your repos to normalize line endings.
  • Credential Manager: If you ever switch to HTTPS, use Windows Credential Manager so you’re not typing tokens every time.
  • WSL Integration: If you use WSL, symlink your SSH keys (ln -s /mnt/c/Users/You/.ssh ~/.ssh) so Git Bash and WSL share the same credentials.

6. Wrap-Up: Your Workflow, Upgraded

Your Windows PC can now host multiple GitHub accounts without breaking a sweat, and your branch strategy has crystal‑clear organization. No more “Which email did I set here?” panics, no more stray pushes, and no more chaotic branch names.

Go forth and code with confidence—on Windows. When Git asks “Who am I?”, you’ll have the right answer every time. Happy hacking! 🎉

Please Like, Comment and Share

Image description

Top comments (0)

Some comments may only be visible to logged-in visitors. Sign in to view all comments.