本地idea项目push到GitHub失败

vbnet 复制代码
18:04:21.656: [group-buy-market-yyb] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/251028-yyb-introduce-wrench:refs/heads/251028-yyb-introduce-wrench --set-upstream
fatal: unable to access 'https://github.com/pnyyb/group-buy-market-yyb.git/': Failed to connect to github.com port 443 after 21093 ms: Could not connect to server

解决方案 git config --global http.proxy git config --global https.proxy

1. Git 的网络请求逻辑

Git 是一个分布式版本控制系统,当你执行 git clonegit pullgit push 等操作时,它会通过 ** 网络协议(如 HTTPS)** 与远程仓库(比如 GitHub)通信。

以 GitHub 为例,它的 HTTPS 服务运行在 443 端口(这是 HTTPS 协议的默认端口)。你的本地 Git 客户端需要通过这个端口与 GitHub 服务器建立连接,才能完成代码的拉取、推送等操作。

2. 代理的作用(为什么配置代理后能成功)

如果你所在的网络环境(比如公司内网、校园网)无法直接访问外网 ,或者需要通过特定的 "中转服务器"(即代理服务器 )才能访问外网,那么 Git 直接请求 github.com:443 就会失败(因为网络被拦截或无法直达)。

此时,你需要让 Git 把所有网络请求转发到代理服务器,由代理服务器帮你完成与 GitHub 的通信。

  • 当你执行 git config --global http.proxygit config --global https.proxy 时,其实是在配置 Git 如何使用代理

    • http.proxy:指定 Git 发送 HTTP 请求时使用的代理地址;
    • https.proxy:指定 Git 发送 HTTPS 请求时使用的代理地址。
  • 配置完成后,Git 不再直接请求 github.com:443,而是把请求发送到代理服务器,由代理服务器去访问 GitHub,再把响应返回给你。这样就绕过了本地网络的限制,成功建立了连接。

总结

这个问题的本质是网络访问的 "可达性" 问题:你的本地网络无法直接连接 GitHub 的 443 端口,但通过配置代理,让 Git 借助代理服务器完成了网络通信,因此操作就成功了。

相关推荐
wangruofeng2 小时前
7.1 万 Star 的 MinerU,把 PDF 变成 LLM 能读懂的 Markdown
github
wangruofeng2 小时前
75k Star 的 OCR 传奇——Tesseract 的 40 年,从 HP 实验室到 LSTM 神经网络
github
逛逛GitHub5 小时前
又挖到 3 个不错的 GitHub 项目,尤其是第 2 个。
github
逛逛GitHub5 小时前
GitHub 上 13 万星的爬虫神器,不要 API Key 就能用了。
github
一点一木13 小时前
🚀 2026 年 6 月 GitHub 十大热门项目排行榜 🔥
人工智能·github
OpenTiny社区1 天前
从零开发 AI 聊天页要两周?试试这款 Vue3 垂直对话组件库 TinyRobot,直接开箱即用
前端·vue.js·github
逛逛GitHub1 天前
2 万多 Star!Google 开源了这个神级 GitHub 项目。
github
逛逛GitHub1 天前
免费 Token 烧掉 5 万亿之后,他们出了个一站式创作平台。
github
用户805533698031 天前
RK-Forge外设系列开篇 - 把板子从「能启动」变成「能用」:Ethernet/SPI/MMC 三个纯接线外设
linux·github·嵌入式
inhere1 天前
eget:不用等中央仓库,直接安装 GitHub 和任意下载站的工具
程序员·开源·github