See guideline to create a new SSH key
$ ssh-keygen -t rsa -C "[email protected]"
Choose/rename the keys, for example like these
~/.ssh/id_rsa_xxx
~/.ssh/id_rsa_yyy
Clear cached SSH keys first
$ ssh-add -D
Add new keys
$ ssh-add ~/.ssh/id_rsa_xxx
$ ssh-add ~/.ssh/id_rsa_yyy
Recheck the keys list
$ ssh-add -l
$ cd ~/.ssh/
$ touch config
$ vi config
Then added
# Identity for xxx repos here
Host github-xxx
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_xxx
IdentitiesOnly yes
# Identity for yyy repos here
Host github-yyy
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_yyy
IdentitiesOnly yes
Clone your repo by alternative url
$ git clone git@github-xxx:xxx/xxx.git xxx
$ git clone git@github-xxx:yyy/yyy.git yyy
Or modify config for existing working directory
$ cd xxx
$ git remote set-url origin git@github-xxx:xxx/xxx.git
$ cd yyy
$ git remote set-url origin git@github-yyy:yyy/yyy.git
Update user name and email to for commit/push
$ cd xxx
$ git config user.name "xxx"
$ git config user.email "[email protected]"
$ cd yyy
$ git config user.name "yyy"
$ git config user.email "[email protected]"