repo1: github.com:myOrg/repo1.git
repo2: github.com:myOrg/repo2.git
Create two SSH Keys. Follow: https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/
key1: repo1_id_rsa
key2: repo2_id_rsa
Add keys:
eval `ssh-agent`
ssh-add ~/.ssh/repo1_id_rsa
ssh-add ~/.ssh/repo2_id_rsa
Make new file in ~/.ssh
vim config
Host repo1.github.com
HostName github.com
User git
IdentityFile /home/myUser/.ssh/repo1_id_rsa
IdentitiesOnly yes
Host repo2.github.com
HostName github.com
User git
IdentityFile /home/myUser/.ssh/repo2_id_rsa
IdentitiesOnly yes
Now you can git clone your repositories:
git clone repo1.github.com:myOrg/repo1.git
git clone repo2.github.com:myOrg/repo2.git
If the repositories are already cloned, edit your origin uri to the above uri by either editing the repo1/.git/config
file
and then simply modifying the origin uri by adding repo1
or repo2
in front of github.com in [email protected]
part.
Or remove the origin by using git remote rm origin
and add a new origin with the above uri by doing git remote add origin <uri>