参考:git 设置和取消代理 (github.com)

拉取 github 上面的仓库时,速度总是非常的慢,通过设置代理即可解决该问题

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# 协议、ip、端口根据实际情况更改
# 临时代理,只针对当前窗口(推荐)
export ALL_PROXY=socks5://127.0.0.1:1080

# 配置代理(gitbash环境下加不加单双引号都可以,生成的配置文件都一样)
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 -e
git config --global --list
git config --global --get http.proxy
git config --global --get https.proxy

# 清除代理
git config --global --unset http.proxy
git config --global --unset https.proxy

# 测试是否走代理(此种方式测试无法证明没有走代理,实测上述方法中只有临时配置生效,而全局配置方式Timeout,但实际clone仓库时都走的代理)
curl www.google.com

代理前后速度对比(速度感人):

配置代理和不配置代理git速度对比