1.问题
国内下载 github 的代码速度令人汗颜,10~60KB/s。 尝试了几种加速下载的方案,,有的挺不错,有的无效。
下面分享一个先在国内同步,之后在github同步的多仓库管理方法。
2.实例
1.github 找到要同步的代码
https://github.com/giuspen/cherrytree
2.在国内git托管上,查找是否相同的git库
3.同步国内的代码
git clone https://gitee.com/imaus/cherrytree.git
等待同步完成
4.添加github 远程仓库
命令原型:
git remote add -t master origin url
注释:
-t master 指定master分支
origin 定义一个远程仓库名
url 远程仓库地址
git remote -t master github https://github.com/giuspen/cherrytree.git
注释:本例-t 指定master分支,定义 远程仓库变量github 地址为 https://github.com/giuspen/cherrytree.git
确认
$ git remote -v
github https://github.com/giuspen/cherrytree.git (fetch) #添加github 远程仓库成功
github https://github.com/giuspen/cherrytree.git (push)
origin https://gitee.com/imaus/cherrytree.git (fetch)
origin https://gitee.com/imaus/cherrytree.git (push)
5.更新github 仓库的代码
git fetch github master
确认:
$ git br -a
* master
remotes/github/master #同步github代码成功
remotes/origin/0.36.x
remotes/origin/0.37.x
remotes/origin/HEAD -> origin/master
remotes/origin/master
remotes/origin/pygi
6.切换到github 的代码上
方法1:
git rebase remotes/github/maste
方法2:
git checkout remotes/github/maste
git br -D master #删除原来的master分支
3.此方案的注意事项
优点:
1.同步速度快
缺点
1.需要gitee 等国内托管,有相同的项目。
2.如果需要提交代码,需要对git多仓库管理的原理,命令熟悉。