![040de0d6239bd0f55c85de1abc772b83.png](https://i-blog.csdnimg.cn/blog_migrate/e28a6c62c849c4cdfd03fbae99e557ea.jpeg)
原发布时间:2019-09-11
原发布地址:本地Git仓库关联多个远程仓库的两种方法
背景
通常情况下,一个本地Git仓库对应一个远程仓库,每次pull
和push
仅涉及本地仓库和该远程仓库的同步;然而,在一些情况下,一个本地仓库需要同时关联多个远程仓库,比如:同时将一个项目发布在Github和Coding上,以兼顾国内外的访客。
那么,如何让一个本地仓库同时关联多个远程仓库呢?
方法1:每次push
、pull
时需分开操作
首先,查看本地仓库所关联的远程仓库:(假定最初仅关联了一个远程仓库)
$ git remote -v
origin git@github.com:keithnull/keithnull.github.io.git (fetch)
origin git@github.com:keithnull/keithnull.github.io.git (push)
然后,用git remote add <name> <url>
添加一个远程仓库,