-
First, create a new SSH key and link it to the new GitHub account you want to use. When prompted to choose the file, change it to another different than the default one. Remember to give a full path, otherwise it will be created on the current directory. This is the process for this step: https://help.github.com/articles/generating-ssh-keys/
-
Add the hosts on /Users/dev/.ssh/config. If the file doesn't exist, create it. Example:
Host github.com-anabellaspinelli HostName github.com User git IdentityFile /Users/dev/.ssh/id_rsa_personal IdentitiesOnly yes Host github.com-anabella-spinelli-company HostName github.com User git IdentityFile /Users/dev/.ssh/id_rsa IdentitiesOnly yes -
Clone/initialize the repo.
-
Add/change the remote to the repo using the corresponding host.
-
For cloned repositories:
git remote set-url origin [email protected]:anabellaspinelli/mockiavelli.git -
For new repositories (originally initialized locally):
git remote add origin [email protected]:anabellaspinelli/mockiavelli.git -
The format is:
{user}@{host}:{GitHubUser}/{repository}.git
-
The most important part, tell the repo who you are, set up user.name and user.email for that repo. Example:
git config --local user.name "Anabella Spinelli" git config --local user.email "[email protected]"
Now for every new repo that you clone you must specify which account on your git config you will use and set up a valid username and email for it (steps 4 and 5).
Worked like a charm! Thanks!