内容纲要
方法一 使用国内映射站
镜像网站(可以访问网页,可以用来clone push,和直接使用github体验相同)
https://hub.fastgit.xyz 可浏览器直接访问,此站备用域名:https://hub.fastgit.org
使用命令行clone工程时慢的解决方法
原始clone命令:
git clone https://github.com/tensorflow/tensorflow.git
替换后的clone命令:
git clone https://hub.fastgit.xyz/tensorflow/tensorflow.git
下载github文件慢的解决方法
对请求url做替换即可(将github.com
替换为download.fastgit.org
),示例如下:
github原始下载地址:
https://github.com/btnkij/qsv2flv/releases/download/beta-test/qsv2flv-beta-x64.exe
替换后的地址:
https://download.fastgit.org/btnkij/qsv2flv/releases/download/beta-test/qsv2flv-beta-x64.exe
方法二 kx上网(购买或自己搭建梯子访问)
传送门
已经kx上网,git clone 速度还是慢的解决方法
分辨需要设置的代理
-
HTTP 形式:
git clone https://github.com/owner/git.git
-
SSH 形式:
git clone git@github.com:owner/git.git
第一种https形式解决方法
走 HTTP 代理
git config --global http.proxy "http://127.0.0.1:8080"
git config --global https.proxy "http://127.0.0.1:8080"
走 socks5 代理(如 Shadowsocks)
git config --global http.proxy "socks5://127.0.0.1:1080"
git config --global https.proxy "socks5://127.0.0.1:1080"
取消设置
git config --global --unset http.proxy
git config --global --unset https.proxy
第二种ssh形式解决方法
修改 ~/.ssh/config 文件(不存在则新建):
# 必须是 github.com
Host github.com
HostName github.com
User git
# 走 HTTP 代理
# ProxyCommand socat - PROXY:127.0.0.1:%h:%p,proxyport=8080
# 走 socks5 代理(如 Shadowsocks)
# ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
方法三 使用gitee做中转
对经常访问的项目可以使用gitee的镜像功能将工程复制自己的repository
- 登录gitee,头像旁边有+号
- 点击+号,选择"从github或gitlab导入仓库"
- 导入完成后就可以使用gitee网址进行clone和push了
方法四 修改hosts文件或者dns
这种方式修改比较麻烦,并且很容易失效,解决的是网络波动的问题,就算可以访问,速度也不会很快,不推荐。优先使用上述三种方式
传送门
参考文章
开启 https & ssh 代理,让 git clone 快到飞起 https://juejin.cn/post/6847902220420120589
https://gist.github.com/chuyik/02d0d37a49edc162546441092efae6a1
一篇文章完美解决国内无法访问github、github文件下载慢问题