Managing Multiple GitHub Accounts: A Developer's Guide

In today's development landscape, it's common to maintain separate GitHub accounts for work and personal projects. This setup helps keep professional and personal contributions clearly separated. Here's a step-by-step guide on how to manage multiple GitHub accounts on a single machine.
Why Multiple GitHub Accounts?
There are several reasons why you might want to maintain multiple GitHub accounts:
Separating work and personal projects
Managing different organizations
Maintaining distinct online identities
Compliance with workplace policies
Step-by-Step Configuration Guide
1. Creating SSH Keys
First, generate unique SSH keys for each account. Open your terminal and run:
# For personal account
ssh-keygen -t ed25519 -C "personal@email.com" -f ~/.ssh/id_ed25519
# For work account
ssh-keygen -t ed25519 -C "work@email.com" -f ~/.ssh/id_ed25519_work
2. Setting Up SSH Agent
Add your new SSH keys to the SSH agent:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
ssh-add ~/.ssh/id_ed25519_work
3. GitHub Configuration
Add your public keys to their respective GitHub accounts:
Copy the content of each
.pubfileGo to GitHub Settings → SSH and GPG keys
Click "New SSH key" and paste your key
4. SSH Config Setup
Create or modify your SSH config file (~/.ssh/config):
# Personal (Default) account
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
# Work account
Host github-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
Using Your Configuration
Cloning Repositories
For personal repositories:
git clone git@github.com:personal-username/repo.git
For work repositories:
git clone git@github-work:work-organization/repo.git
Repository-Specific Configuration
Set up Git configuration for each repository:
# Personal repository
git config user.name "Full Name"
git config user.email "personal@email.com"
# Work repository
git config user.name "Full Name"
git config user.email "work@email.com"
Conclusion
Managing multiple GitHub accounts might seem daunting at first, but with proper configuration, it becomes a seamless part of your development workflow. This setup helps maintain a clean separation between different aspects of your development life while ensuring secure access to all your repositories.

