github快速下载方案 多仓库管理:同步国内 github多仓库

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多仓库管理的原理,命令熟悉。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值