1概述
目前在国内拉取github代码时会遇到速度慢问题。目前主要有三种方法:
- 修改hosts文件,添加github.com和github.global.ssl.fastly.net对应的ip
- 挂上代理,设置git config --global https.proxy http://127.0.0.1:1080(或http)
- 使用镜像代替
以上三种方法优先推荐方法3,其中代替镜像可以通过以下两种方式获得:
- 使用已有镜像替换
- 创建镜像替换
2加速方法举例
常规拉取代码操作如下:
git clone https://github.com/user/xxx-repositories.git
2.1使用已有镜像
国内已有的快速镜像:
快速镜像:https://github.com.cnpmjs.org
下载速度慢时,采用以下镜像替代方法:
//将https://github.com替换为 https://github.com.cnpmjs.org
git clone https://github.com.cnpmjs.org/user/xxx-repositories.git
2.2创建镜像
使用GitLee等其他在国内的代码托管服务器创建github镜像
以GitLee为例:
新建repositories,选择从github中导入,这样就在GitLee中得到了一个repositories镜像。
然后从GitLee中拉取代码。