分享一个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
相关推荐
武超杰2 小时前
Git 从入门到精通教程
git
程序员夏末3 小时前
【开源经历 | 第一篇】参与开源需要掌握的Git和Github指令
git·开源
SNOWPIAOP4 小时前
git status 出现中文乱码的解决方案等
git·乱码·postgres
qq_4352879215 小时前
第9章 夸父逐日与后羿射日:死循环与进程终止?十个太阳同时值班的并行冲突
java·开发语言·git·死循环·进程终止·并行冲突·夸父逐日
AIMath~21 小时前
Git 子模块(Submodule)目录结构清除实战复盘
git
切糕师学AI1 天前
Ubuntu 下 Git 完全使用指南
linux·git·ubuntu
一袋米扛几楼981 天前
【Git】规范化协作:详解 GitHub 工作流中的 Issue、Branch 与 Pull Request 最佳实践
前端·git·github·issue
尘埃落定wf1 天前
# GitHub CLI:告别繁琐的 Git 命令,让开发更高效
git·github
恋喵大鲤鱼1 天前
git clone
git·git clone
金牛IT1 天前
Gogs 轻量级 Git 服务器搭建与使用
运维·服务器·git