Skip to content

I have two github accounts (one for work and one personal) and I want to be able to access repositories from either account from my laptop without switching users locally.  I have separate rsa public keys for each account but needed an easy way to force git to know which one to use. Here’s what I am doing:

#Default GitHub user (work)
 User git  
 IdentityFile /Users/USERNAME/.ssh/id_rsa 

# Personal user 
 Host github-personal  
 User git  
 IdentityFile /Users/USERNAME/.ssh/id_rsa_personal 

Then when I create a new github repository for personal use:

`git remote add origin git@github-personal:username/project.git`

or for work

`git remote add origin`

If am cloning an existing repository it works the same way:

`git clone `
`git clone git@github-personal:username/project.git `