分享一个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
相关推荐
满天星830357710 分钟前
【Git】原理及使用(三)(分支管理)
linux·git
像风一样的男人@4 小时前
warning: could not find UI helper ‘git-credential-manager-ui‘
git·ui
代钦塔拉5 小时前
Git & GitHub 从入门到精通:全流程实战教程
git·github
晚风吹红霞6 小时前
Linux下的趣味编程 —— 进度条、Git版本控制与GDB调试实战
linux·运维·git
xlq223227 小时前
7.git
git
Ws_7 小时前
Git + Gerrit 第六课:commit --amend、Patch Set 与 Change-Id
git
AIMath~1 天前
向github中上传文件过大超过50M怎么办
网络·git·github
AIMath~1 天前
如何将一个新的文件夹使用git 工具提交到github新仓库中
git·github
满天星83035771 天前
【Git】原理及使用(二) (版本回退)
linux·git
愿天垂怜1 天前
【C++脚手架】ffmpeg 库的介绍与使用
linux·服务器·开发语言·c++·ide·git·ffmpeg