create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "your_email@youremail.com" -f account_1
$ ssh-keygen -t rsa -C "your_email@youremail.com" -f account_2
Please refer to github ssh issues for common problems.
for example, 2 keys created at:
~/.ssh/account_1
~/.ssh/account_2
first you can delete all keys before
$ ssh-add -D
then, add these two keys as following
$ ssh-add ~/.ssh/account_1
$ ssh-add ~/.ssh/account_2
finally, you can check your saved keys
$ ssh-add -l
$ cd ~/.ssh/
$ touch config
$ vi config
Then added
#account_1
Host github-account-1
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/account_1
IdentitiesOnly yes
#account_2
Host github-account-2
HostName github.com
User git
PreferredAuthentications publickey
IdentityFile ~/.ssh/account_2
IdentitiesOnly yes
Test SSH connect
$ ssh -T git@github-account-1
$ ssh -T git@github-account-2
clone your repo
git clone git@github-account-1:user1's github username/project.git project1
...or for an existing working directory
git remote set-url origin git@github-account-1:user1's github username/project.git
cd project1 and modify git config
$ git config user.name "user1"
$ git config user.email "user1@gmail.com"
or you can have global git config
$ git config --global user.name "user1"
$ git config --global user.email "user1@gmail.com"
then use normal flow to push your code
$ git add .
$ git commit -m "your comments"
$ git push
http://stackoverflow.com/questions/3225862/multiple-github-accounts-ssh-config
https://gist.github.com/RichardBronosky/dc0ced21d6dc7be7d196
http://blog.chinaunix.net/uid-20749137-id-718749.html