More Git accounts. One machine. No conflicts.
SSH config, per-repo identity, and a setup that keeps work and personal remotes from stepping on each other.
Darshil Patel1 min read
One laptop, two GitHub accounts, zero accidental commits as the wrong person. This is the setup I use daily.
The problem
Git identity is global by default. SSH keys are one per host unless you tell OpenSSH otherwise. If you use git@github.com for everything, GitHub sees one key and one account.
The fix: host aliases
In ~/.ssh/config:
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_work
IdentitiesOnly yes
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personal
IdentitiesOnly yes
Clone with the host alias, not github.com:
git clone git@github.com-work:org/repo.git
Per-repo identity
Inside each repo:
git config user.email "you@work.com"
git config user.name "Your Name"
Personal repos get your personal email. Work repos get work. No global user.email that you forget to override.
Quick sanity check
ssh -T git@github.com-work
ssh -T git@github.com-personal
Each should greet the correct account. If not, the key or IdentitiesOnly line is wrong — fix that before your next push.