下面的命令只針對github.com
,在國內還可能會用到gitee.com
,所以不能將所有的 git 站點都添加上代理。
# 設置代理
git config --global http.https://github.com.proxy socks5://127.0.0.1:1086
# 取消代理
git config --global --unset http.https://github.com.proxy
如果沒有代理也不要急,有專門的cdn加速:
git config --global url."https://github.com.cnpmjs.org".insteadOf "https://github.com"
git config --global url."https://ghproxy.com/https://github.com".insteadOf "https://github.com"
或者:
git config --global url."https://hub.fastgit.xyz/".insteadOf "https://github.com/"
cdn 加速二選一使用。
但因為沒有官方 CDN,上面兩個都是用愛發電,沒准哪天就掛了。