Create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com"
For example, 2 keys created at:
~/.ssh/id_rsa_acc_a
~/.ssh/id_rsa_acc_b
then, add these two keys as following
$ ssh-add ~/.ssh/id_rsa_acc_a
$ ssh-add ~/.ssh/id_rsa_acc_b
you can delete all cached keys before
$ ssh-add -D
finally, you can check your saved keys
$ ssh-add -l
$ cd ~/.ssh/
$ touch config
$ vim config
Then added
#activehacker account
Host github.com-id_rsa_acc_a
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_acc_a
#jexchan account
Host github.com-id_rsa_acc_b
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_acc_b
You can also modify the hostname in case you have another git repos host (not just github)
clone your repo and modify git config in each cloned folder. git clone git@github.com:gitaccount/gfs.git repository_name
cd repository_name and modify git config
$ git config user.name "any user name you want"
$ git config user.email "your email that used for this repos commit and push"
or you can have global git config $ git config --global user.name "any user name you want" $ git config --global user.email "your global email"
then use normal flow to push your code
$ git add .
$ git commit -m "your comments"
$ git push