create different ssh key according the article Mac Set-Up Git
$ ssh-keygen -t rsa -C "[email protected]"
Please refer to github ssh issues for common problems.
for example, 2 keys created at:
~/.ssh/id_rsa_home
~/.ssh/id_rsa_work
then, add these two keys as following (Đoạn này có thể không add được có thể bỏ qua)
$ ssh-add ~/.ssh/id_rsa_home
$ ssh-add ~/.ssh/id_rsa_work
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
#home account
Host github.com-home
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_home
#work account
Host github.com-work
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_work
clone your repo
git clone [email protected]:accountname/gfs.git gfs_work
cd gfs_work (Project vừa clone ở trên, để edit file config) and modify git config
$ git config user.name "work"
$ git config user.email "[email protected]"
$ git config user.name "home"
$ git config user.email "[email protected]"
or you can have global git config $ git config --global user.name "work" $ git config --global user.email "[email protected]"
then use normal flow to push your code
$ git add .
$ git commit -m "your comments"
$ git push