应用git把一个本地仓库同时push到多个近程仓库

1. 首先须要别离新建近程仓库

本次次要同时push到giteegithub

2. 从github拉取代码到本地

# 从github拉取代码到本地$ git clone https://github.com/dragonishare/totoro.git# 查看本地仓库关联的近程仓库状况$ git remote -vorigin  https://github.com/dragonishare/totoro.git (fetch)origin  https://github.com/dragonishare/totoro.git (push)

3. 增加新的近程仓库

通过git remote set-url --add 别名 仓库地址增加新的近程仓库

$ git remote set-url --add origin https://gitee.com/dragonishare/totoro.git# 查看本地仓库关联的近程仓库状况$ git remote -vorigin  https://github.com/dragonishare/totoro.git (fetch)origin  https://github.com/dragonishare/totoro.git (push)origin  https://gitee.com/dragonishare/totoro.git (push)

githubgitee都应用默认的近程版本库名称origin,不便同时推送

4. 留神

本地仓库能够同时推送到githubgitee,但只能从github拉取

5. 能够通过间接批改.git/config文件来实现同样的性能

# 找到remote origin,增加url = 仓库地址[remote "origin"]        url = https://github.com/dragonishare/totoro.git        fetch = +refs/heads/*:refs/remotes/origin/*        url = https://gitee.com/dragonishare/totoro.git