HTTP/HTTPS代理
bash
# HTTP/HTTPS 代理
git clone -c http.proxy="代理地址" -c https.proxy="代理地址" 仓库地址
举个例子:
bash
git clone -c http.proxy=127.0.0.1:10808 https://github.com/MoonshotAI/kimi-cli.git
SOCKS5 代理(推荐,兼容性更好)
bash
git clone -c http.proxy="socks5://代理地址" -c https.proxy="socks5://代理地址" 仓库地址
全局生效:所有 Git 操作都走代理
bash
# 1. HTTP/HTTPS 代理
git config --global http.proxy "http://127.0.0.1:7890"
git config --global https.proxy "http://127.0.0.1:7890"
# 2. SOCKS5 代理(推荐)
git config --global http.proxy "socks5://127.0.0.1:7891"
git config --global https.proxy "socks5://127.0.0.1:7891"
# 3. 若代理需要账号密码(如公司代理)
git config --global http.proxy "http://用户名:密码@代理地址:端口"
git config --global https.proxy "http://用户名:密码@代理地址:端口"
取消全局代理(不需要时):
bash
git config --global --unset http.proxy
git config --global --unset https.proxy