Git连接Github远程仓库的代理设置

在使用git命令克隆github远程仓库的代码时,遇到了如下443错误,原因是网络连接问题导致无法访问 GitHub 服务器。

考虑到可能是代理设置的问题

  • 查看全局代理设置
bash 复制代码
git config --global --get http.proxy
git config --global --get https.proxy

# 如果有返回结果,这说明已配置代理
# http://127.0.0.1:7890
# https://127.0.0.1:7890

# 若未返回任何内容,则表示当前没有全局代理配置
  • 若使用代理,需确保 Git 已正确配置代理:
bash 复制代码
# 设置代理(替换为你的代理地址)
# 默认127.0.0.1:7890

# 设置HTTP代理
git config --global http.proxy http://代理地址:端口号
# 设置HTTPS代理
git config --global https.proxy https://代理地址:端口号

# 仅让 GitHub 走代理
git config --global http.https://github.com.proxy http://代理地址:端口
git config --global https.https://github.com.proxy https://代理地址:端口
  • 若不需要代理,可清除代理设置:
bash 复制代码
# 清除全局 HTTP 代理
git config --global --unset http.proxy
# 清除全局 HTTPS 代理
git config --global --unset https.proxy
# 清除仅 GitHub 的代理(如果设置过)
git config --global --unset http.https://github.com.proxy
git config --global --unset https.https://github.com.proxy
  • 验证代理是否生效

可以通过克隆一个 GitHub 仓库(或执行 git fetch)来测试代理是否工作,例如:

bash 复制代码
git clone https://github.com/githubtraining/hellogitworld.git

配置后,只有访问 github.com 相关的仓库时才会走代理,访问其他仓库(如 GitLab、Gitee 等)则不会受影响。

相关推荐
阿智的AI开发笔记13 小时前
充了 200 块只跑出 3 条:AI 视频真正贵的地方,是「按次」和「按秒」的区别
github
GitHub实测笔记13 小时前
rtk 本机实测:给 AI Agent 砍掉 90% 的命令行噪音(Linux)
github
小莫46113 小时前
CI 全绿了,测试却可能是假的:GitHub Actions 三个静默失效的坑
github
dreams_dream15 小时前
项目想要推送多个平台仓库的方法
gitee·github
赵民勇15 小时前
Git命令详解
git
AI_Lab0115 小时前
服务器管理工具要在服务器上装 Agent,安全吗?
服务器·安全·github
七牛云行业应用15 小时前
DeepSeek Harness 插件架构 vs MCP:Cordis 的「Everything is a Plugin」到底解决什么
ai·github·ai编程
u13013016 小时前
GitHub 热榜项目:日榜(2026-10-30)
人工智能·github
AlfredZhao17 小时前
新项目首次提交 GitHub 报错“未配置远端 origin”怎么办
github
miofly17 小时前
GitHub 日榜趋势速报 | 2026-10-31
开源·github