Why This Guide Exists
Many developers use two GitHub accounts:
One for office or company work
One for personal projects
At first everything seems fine, but sooner or later something strange happens:
A commit in your personal project shows your company email
A work repository uses your personal account
This happens because Git is using the same SSH key and global configuration for every repository.
The solution is simple: create separate SSH keys and configure Git to use them correctly.
Once this is set up, you can easily manage both accounts on the same machine without any confusion.
Quick Rule to Remember
Office Work
git@github.com:company/repo.gitPersonal Projects
git@github.com-personal:username/repo.gitThe github.com-personal host tells Git to use your personal SSH key.
One-Time Setup
You only need to do this once, and then everything will work automatically.
1. Create SSH Keys
First, create two SSH keys:
One for work
One for personal use
Office Account
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519 -C "your.name@company.com"Personal Account
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_personal -C "personal@email.com"After running these commands you will have:
~/.ssh/id_ed25519
~/.ssh/id_ed25519.pub
~/.ssh/id_ed25519_personal
~/.ssh/id_ed25519_personal.pubThe .pub files are public keys that need to be added to GitHub.
2. Add Keys to GitHub
Now connect each SSH key to the correct GitHub account.
Copy the office key:
cat ~/.ssh/id_ed25519.pubAdd it to your company GitHub account.
Next copy the personal key:
cat ~/.ssh/id_ed25519_personal.pubAdd it to your personal GitHub account.
You can add these in:
GitHub → Settings → SSH and GPG Keys
3. Create SSH Configuration
Now we configure your system to know which key belongs to which account.
Open the SSH config file:
nano ~/.ssh/configAdd this configuration:
# OFFICE Account (DEFAULT)
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519
# PERSONAL Account
Host github.com-personal
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_personalWhat This Does
github.com→ uses your work accountgithub.com-personal→ uses your personal account
4. Set Your Default Git Identity
Since most developers spend more time working on company projects, we usually set the office identity globally.
git config --global user.name "Your Office Name"
git config --global user.email "your.name@company.com"Now your work repositories will automatically use this identity.
Daily Usage
Once everything is configured, using both accounts becomes very simple.
Office Projects
Clone repositories normally:
git clone git@github.com:company/project.gitUse Git as usual:
git push origin main
git pull origin devGit will automatically use your office SSH key.
Personal Projects
For personal repositories, use the personal host name.
git clone git@github.com-personal:username/project.gitExample:
git clone git@github.com-personal:john/my-portfolio.gitNow Git will use your personal SSH key.
Fix Personal Repository Identity (Optional)
Inside a personal project folder you can set your personal Git identity:
git config user.name "Your Personal Name"
git config user.email "personal@email.com"This ensures commits appear under your personal GitHub account.
Testing the Setup
You can verify everything works correctly.
Test Work Account
ssh -T git@github.comIt should show your company GitHub username.
Test Personal Account
ssh -T git@github.com-personalIt should show your personal GitHub username.
Check Repository Remote
If you ever want to confirm which account a repository is using:
git remote -vExample outputs:
Office repository
git@github.com:company/project.gitPersonal repository
git@github.com-personal:username/project.gitWhen You Join a New Company
If you change jobs, simply generate a new SSH key.
ssh-keygen -t ed25519 -f ~/.ssh/id_ed25519_new -C "new.email@company.com"Update your SSH config:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_ed25519_newYour personal configuration stays the same.
Final Thoughts
Managing multiple GitHub accounts on the same machine might seem tricky at first.
But once you configure:
Separate SSH keys
A simple SSH config
Proper clone URLs
You can switch between work and personal projects effortlessly.
No more authentication issues, no more wrong commits — just a clean and organised development workflow.
Quick Commands Table
Purpose | Command |
|---|---|
Clone work repo |
|
Clone personal repo |
|
Test connections |
|
Check current remote URL |
|
Fix local identity |
|

