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中拉取代碼。