Github 解决 Recv failure: Connection reset by peer

发布时间 2024-01-07 11:26:07作者: 一杯半盏

问题现象

git pull 时报错 Recv failure: Connection reset by peer

问题原因

  1. 第一类:网络问题,这一部分通过命令检查gitconfig 排查是否有 http https proxy的问题。
  2. 第二类:如果通过http协议拉取代码,则可以通过检查MacOS的钥匙串或者Windows 凭据管理器。

具体操作指引参考下方的链接。

Git Credential Manager

2024年了,github 通过GCM + HTTP协议 + Personal Access Token 不是更好?这样就不用每台电脑都配置一份 SSH Keys了。

Git Credential Manager (GCM) is another way to store your credentials securely and connect to GitHub over HTTPS. With GCM, you don't have to manually create and store a personal access token, as GCM manages authentication on your behalf, including 2FA (two-factor authentication).

解决方案

检查 PAT 是否过期

访问 Github 查看 Personal Access Token

Settings -> Developer Settings -> Personal Access Tokens -> Fine-grained personal access tokens

可根据需要,检查以前配置的 Access Token 是否过期,或者 Regenerate 一个新的。

  • Settings 位于 Github 头像处
  • Developer Settings 在左侧导航最后一项

更新电脑系统的凭据管理器

MacOS 的钥匙串访问

搜索 github 找到 IntelliJ Platform Github,则为曾经使用过的凭据。

Windows 的凭据管理器

和 MacOS 的操作类似,查找 github 有关的 Windows 凭据,删除或者更新密码。

参考文章

这篇文章解释了 基于HTTP 和基于ssh的 Git协议的差别。
【Github】解决 git pull不能拉取 HTTP协议的 Git项目