用过一段时间的github,一直挺顺畅,突然用上了coding,略不适应,因此把coding和github上的远程仓库统一同步.

之前设置过SSH key,其值放在目录/.ssh/id_rsa.pub中,注意不是id_rsa,把id_rsa.pub文件中的ssh值放入
此时已经在github和coding中已经设置好了SSH,用git remote set-url命令实现二者的同步
$git remote add both git@git.coding.net:user/project.git
添加一个名为 both 的远端
$git remote set-url --add --push both git@git.coding.net:user/project.git
# 为其添加 push 到 Coding 的 SSH 地址
$git remote set-url --add --push both git@github.com:user/repo.git
# 为其添加 push 到 GitHub 的 SSH 地址
$git remote -v #查看当前远端仓库
origin git@git.coding.net:user/project.git (fetch)
origin git@git.coding.net:user/project.git (push)
github git@github.com:user/repo.git (fetch)
github git@github.com:user/repo.git (push)
之后在推送的时候用git push both实现二者同步更新
可以参考这篇文章https://www.jianshu.com/p/4cd46619b3a5
网友评论