
If you manage both personal and work GitHub accounts, you’ve likely faced problems like:
- Commits showing the wrong email
- Push denied errors
- Accidentally pushing work code with personal account
- Logging in and out repeatedly
This guide shows a professional-grade setup using SSH keys and Git’s conditional configuration.
By the end, you’ll have:
- Multiple GitHub accounts on one machine
- Separate SSH keys per account
- Automatic identity switching by folder
- Clean and reliable Git workflow
SSH allows:
- No password prompts
- Multiple accounts simultaneously
- Fine-grained control over identity
- Secure long-term setup
Create one key per account.
Save as:
Save as:
Copy the public key:
Go to:
GitHub → Settings → SSH & GPG keys → New SSH Key → Paste
Repeat for work key:
Edit SSH config:
Add:
Test:
You should see:
> Hi username! You've successfully authenticated...
GitHub gives:
Change to:
Personal:
Work:
Example:
This is the real power feature.
Edit global git config:
Add:
Inside work repo:
Should show:
- work email
- id_rsa_work
Inside personal repo:
Should show personal email.
Sometimes Git still uses the wrong key.
Check:
If wrong:
Then retry push.
These reveal exactly which key and identity is being used.
After this setup:
- You never manually switch accounts
- Git auto-detects identity by folder
- SSH always uses correct key
- VS Code works automatically
- No more permission denied surprises
This is the same setup used by:
- Freelancers managing multiple clients
- Engineers working across organizations
- Developers contributing to open-source + company projects
- People maintaining strict identity separation
Structure your machine like:
Then Git becomes fully automatic.
Once configured, this setup becomes invisible and frictionless.
You stop thinking about GitHub accounts entirely — everything just works.
If you manage multiple identities, this is one of the highest ROI setups you can make.