Managing Multiple GitHub/Git Accounts on One Machine (Personal + Work)
A Complete Guide to Handling Multiple Git & GitHub Identities on One Machine

Search for a command to run...
A Complete Guide to Handling Multiple Git & GitHub Identities on One Machine

No comments yet. Be the first to comment.
In this Open-Source series, I'll provide you blogs about Git, Github, Open-Source Contribution, and all the main topics of Github and Open-Source. In one line this series is dedicated to Open-Source.
Mastering git cherry-pick: Fix Mistakes, Move Commits, Save Your Day!
What the program actually is, how the application works step by step, and what to do in your first 30 days after selection.

A step-by-step guide to running Ollama, Gemma4, Continue, and Claude Code locally

The Problem If you're reading this, you're probably stuck in the same nightmare I was: Antigravity shows "Authentication Required Please sign in" no matter what you do. You've reinstalled it. You've c

My First Major CNCF Open Source Contribution

Mastering Git Rebase: Fix Wrong Authors the Safe Way (Docker Lab + Real GitHub Practice)

As developers and DevOps engineers, it's common to contribute to both personal and professional projects. However, using two GitHub accounts on a single machine can lead to identity conflicts, unverified commits, or accidentally pushing to the wrong repository.
In this guide Iβll walks you through setting up two GitHub accounts securely, cleanly, and with verified SSH-signed commits all on a single machine.
Work with both personal and work GitHub repositories (public & private).
Use two separate GitHub accounts on one machine.
Ensure verified commits via SSH commit signing.
Maintain a scalable, secure, and professional Git setup.
Create separate SSH key pairs for each GitHub account:
You can name these according to your preferences while generating the SSH keys
for-personal
for-work
# Personal Key
ssh-keygen -t ed25519 -C "you.email@gmail.com" -f ~/.ssh/for-personal
# Work Key
ssh-keygen -t ed25519 -C "you.workemail@gmail.com" -f ~/.ssh/for-work
Do not overwrite the default
id_ed25519. Keeping keys separate ensures flexibility and security.
# View loaded keys
ssh-add -l
# Add new keys
ssh-add ~/.ssh/for-personal
ssh-add ~/.ssh/for-work
# Remove all existing keys (optional reset)
ssh-add -D
config FileCreate or edit your SSH config file:
touch ~/.ssh/config
Add the following content:
# Global settings
Host *
AddKeysToAgent yes
UseKeychain yes
IdentitiesOnly yes
ServerAliveInterval 60
ServerAliveCountMax 3
# Personal GitHub
Host personal.github.com
HostName github.com
User git
IdentityFile ~/.ssh/for-personal
# Work GitHub
Host work.github.com
HostName github.com
User git
IdentityFile ~/.ssh/for-work
Upload the corresponding .pub files to each account:
~/.ssh/for-personal.pub β Personal GitHub
~/.ssh/for-work.pub β Work GitHub
GitHub β Settings β SSH and GPG Keys β New SSH Key
# Clone personal repo
git clone git@personal.github.com:your-username/my-repo.git
# Clone work repo
git clone git@work.github.com:my-org/work-repo.git
Set identity locally inside each project to avoid global conflicts:
# Inside Personal Repo
cd ~/PersonalRepo
git config user.name "your name"
git config user.email "your email"
# Inside Work Repo
cd ~/WorkRepo
git config user.name "your name"
git config user.email "your work email"
GitHub supports SSH-based commit signing, separate from SSH authentication.
# Personal Signing Key
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_signing_personal -C "signing-personal"
# Work Signing Key
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_signing_work -C "signing-work"
Go to GitHub β Settings β SSH and GPG Keys β New Signing Key and paste the contents of each .pub file.
Set up commit signing in each repo:
# Personal Repo
cd ~/PersonalRepo
git config commit.gpgsign true
git config gpg.format ssh
git config user.signingkey ~/.ssh/id_ed25519_signing_personal.pub
# Work Repo
cd ~/WorkRepo
git config commit.gpgsign true
git config gpg.format ssh
git config user.signingkey ~/.ssh/id_ed25519_signing_work.pub
Before making commits in any repository, ensure your SSH agent is running and keys are loaded:
# Ensure SSH agent is running and keys are loaded
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/personal_github
ssh-add ~/.ssh/work_github
# Test connections to verify which account will be used
ssh -T git@personal.github.com
# or
ssh -T git@work.github.com
# Now proceed with your git operations
git add .
git commit -m "Your commit message"
git push origin main
Successful messages like
Hi broh! You've successfully authenticatedconfirm proper setup.
Note: This step is particularly important after system restarts or when opening new terminal sessions, as the SSH agent may not be running or may not have your keys loaded.
Secure and clean GitHub SSH setup for both accounts.
Verified commits using SSH signing keys.
Separate identities per project.
To view signed commits:
git log --show-signature