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

相关推荐
__Witheart__3 小时前
.gitignore 不生效问题——删除错误追踪的文件
git
月临水5 小时前
Git 学习笔记
笔记·git·学习·1024程序员节
zhu_superman7 小时前
Git 中忽略 Mac 生成的 .DS_Store文件
git·macos
绝无仅有10 小时前
腾讯面试文章解析:MySQL慢查询,存储引擎,事务,结构算法等总结与实战
后端·面试·github
x70x8010 小时前
git仓库基本使用
git·算法·编程
我要升天!10 小时前
Git的原理与使用 -- 基础操作
大数据·服务器·git·elasticsearch
__Witheart__10 小时前
记git status不显示已追踪文件文件的更改
git
逛逛GitHub11 小时前
这个 OCR 开源项目天花板,杀疯了。
github
徐sir(徐慧阳)12 小时前
搭建属于自己的网站HEXO静态页(二)发布网站到gihub
服务器·node.js·github·hexo
哈喽哈喽哈喽~12 小时前
推送文件到github ---服务器关键配置内容
运维·服务器·经验分享·github