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 等)则不会受影响。

相关推荐
HelloGitHub27 分钟前
从一份 README 到 3 万星,RustFS 这一年都干了什么?
开源·github
青峰客1 小时前
DeepSeek 大模型新手快速上手指南
运维·服务器·github
别动我齐刘海1 小时前
ROS2 Jazzy + C++ 实战路线——基础学习1
c++·vscode·python·ubuntu·机器学习·自动驾驶·github
天天喝旺仔1 小时前
Git 内部原理深度解析:从 blob/tree/commit 对象到 packfile 与垃圾回收
数据结构·数据库·git·算法·哈希
艾莉丝努力练剑1 小时前
【Git:综合复盘】Git 原理与使用
大数据·人工智能·git·elasticsearch·面试
是2的10次方啊2 小时前
Grill Me:开工前先被拷问一遍
github
niucloud-admin12 小时前
JAVA V6 多商户商城 开发文档——job 计划任务开发
java·python·github
峰向AI17 小时前
Notion 太贵?这个 40K Star 的开源知识库,让你零成本搭建团队 wiki
github
逛逛GitHub18 小时前
37K Star 的 GitHub 开源项目开放 AI 网关,10 人团队免费用。
github
FuckPatience19 小时前
Git:the remote end hung up unexpectedly,Everything up-to-date
github