git代理设置与取消

git代理设置与取消

设置http代理

git config --global http.proxy http://127.0.0.1:1080

git config --global https.proxy https://127.0.0.1:1080

设置 socks5 代理

git config --global https.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

只对某一个 git 或远端仓库设置或取消代理

只对 github 设置代理

#只对github.com
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080

#取消代理    
git config --global --unset http.https://github.com.proxy)

只对本地仓库设置代理

# 设置
git config --local https.proxy http://127.0.0.1:1080

# 取消
git config --global --unset http.https://github.com.proxy)

查看代理代理

git config  --list

git config --global --get http.proxy
git config --global --get https.proxy

总结

配置文件类型

git config 是配置文件,但提供了通过命令来管理。总共有三份配置文件,分别是:

  • –global 全局配置
  • –system 系统配置
  • –local 本地仓库

具体选哪一种可以根据自己的情况灵活选择。

至于代理, 常用的基本上有 http 和 socks5 两种, http 是应用层的协议, socks5 是工作在传输层的,通常效率较高。 我们常用的 shdowsocks 提供的是 socks5 代理,当让也有一些新的 shadowsocks 客户端版本提供了本地 http 代理等其他功能。

如果你觉得本文对你有帮助,欢迎打赏!