分享一个git设备代理的方法

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
相关推荐
春日见13 小时前
如何创建一个PR
运维·开发语言·windows·git·docker·容器
stevenzqzq1 天前
git 常用操作
大数据·git
Curvatureflight1 天前
Git工作流最佳实践:从混乱到优雅
git
wu~9701 天前
GitHub永不遗忘,使用git push -f来覆盖的提交依旧保留
git·github
Vermouth_002 天前
git clone的时候提示access denied
git
qq_437657272 天前
清楚本地的git并重新登录
git
jiang_changsheng2 天前
工作流agent汇总分析 2
java·人工智能·git·python·机器学习·github·语音识别
顶点多余2 天前
版本控制器-git
linux·git
夔曦2 天前
Git工程日常下拉/上传完整流程(自用)
git
岱宗夫up2 天前
GitHub Desktop如何设置中文?这不是个简单问题
git·github