Add multiple remote git locations

  • create new ssh by ssh-kegen
  • edit /.ssh/config
  • git remote add

Add multiple remote git locations

# create new ssh key
$ ssh-keygen -t rsa -C "name@abc.com" -f $HOME/.ssh/yournewsssh

# create new ssh config
$ vi ~/.ssh/config
Host code.aliyun.com
  Hostname code.aliyun.com
  IdentityFile ~/.ssh/yournewsssh
  IdentitiesOnly yes
  
# add remote alias & push
$ git remote add aliyun git@code.aliyun.com:xxx/xxx.git
$ git push aliyun master
Counting objects: 1546, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (1443/1443), done.
Writing objects: 100% (1546/1546), 3.46 MiB | 2.79 MiB/s, done.
Total 1546 (delta 544), reused 947 (delta 37)
remote: Resolving deltas: 100% (544/544), done.
 * [new branch]      master -> master

References