git clone老是失败,试试设置代理

703 阅读1分钟

git clone老是失败,试试设置代理

使用 HTTP 或 HTTPS 协议连接到 Git 仓库的代理方法

# HTTP/HTTPS 协议,port 需与代理软件设置的一致
git config --global http.proxy http://127.0.0.1:port  # 注意修改 port

# SOCKS5 协议,port 需与代理软件设置的一致
git config --global http.proxy socks5://127.0.0.1:port  # 注意修改 port

针对特定域名的 Git 仓库

# HTTP/HTTPS 协议
git config  --global http.url.proxy http://127.0.0.1:port
# 以 Github 为例
git config --global http.https://github.com.proxy http://127.0.0.1:port

# SOCKS5 协议
git config --global http.url.proxy socks5://127.0.0.1:port
# 以 Github 为例
git config --global http.https://github.com.proxy socks5://127.0.0.1:port