create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -b 4096 -C "[email protected]"
Please refer to github ssh issues for common problems.
for example, 2 keys created at:
~/.ssh/id_rsa_kunyi_xxx
~/.ssh/id_rsa_kunyi_yyy
then, add these two keys as following
$ ssh-add ~/.ssh/id_rsa_kunyi_xxx
$ ssh-add ~/.ssh/id_rsa_kunyi_yyy
you can delete all cached keys before
$ ssh-add -D
finally, you can check your saved keys
$ ssh-add -l
$ cd ~/.ssh/
$ touch config
$ subl -a config
Then added
#kunyi@1 account
Host github.com-kunyi-1
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_kunyi_xxx
#kunyi@2 account
Host github.com-kunyi-2
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_kunyi_yyy
clone your repo git clone [email protected]:activehacker/gfs.git gfs_jexchan
cd gfs_jexchan and modify git config
$ git config user.name "jexchan"
$ git config user.email "[email protected]"
$ git config user.name "activehacker"
$ git config user.email "[email protected]"
or you can have global git config $ git config --global user.name "jexchan" $ git config --global user.email "[email protected]"
then use normal flow to push your code
$ git add .
$ git commit -m "your comments"
$ git push
Another related article in Chinese
for example:
kunyi@ubuntu-build:~/cip-core/linux-cip-4.19$ cat ~/.ssh/config
ForwardAgent yes
Host github.com-kunyi_gmail
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa-kunyi_gmail
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa
kunyi@ubuntu-build:~/cip-core/linux-cip-4.19$ git remote add github [email protected]_gmail:KunYi/linux-cip-4.19.git