首页 > 解决方案 > Gitlab - 无法推送到存储库只是挂起

问题描述

无法推送到主控,控制台只是冻结而没有任何响应。只有在运行之后

git config --global http.postBuffer 524288000

git push工作得很好。

虽然设置似乎是一次,但下次使用时会遇到git push同样的问题。有替代解决方案吗?为什么会突然发生这种情况?

编辑:

OpenSSH_7.9p1, LibreSSL 2.7.3 debug1: Reading configuration data /Users/name/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48: Applying options for * debug2: resolving "gitlab.com" port 22 debug2: ssh_connect_direct debug1: Connecting to gitlab.com [2606:4700:90:0:f22e:fbec:5bed:a9b9] port 22. debug1: Connection established. debug1: identity file /Users/name/.ssh/id_rsa type 0 debug1: identity file /Users/name/.ssh/id_rsa-cert type -1 debug1: identity file /Users/name/.ssh/id_dsa type -1 debug1: identity file /Users/name/.ssh/id_dsa-cert type -1 debug1: identity file /Users/name/.ssh/id_ecdsa type -1 debug1: identity file /Users/name/.ssh/id_ecdsa-cert type -1 debug1: identity file /Users/name/.ssh/id_ed25519 type -1 debug1: identity file /Users/name/.ssh/id_ed25519-cert type -1 debug1: identity file /Users/name/.ssh/id_xmss type -1 debug1: identity file /Users/name/.ssh/id_xmss-cert type -1 debug1: Local version string SSH-2.0-OpenSSH_7.9

标签: gitgitlab

解决方案


您看到的是某种网络问题。您可以连接到远程系统,但无法读取远程端的版本字符串,这是它作为 SSH 协议的一部分发送的第一件事。

您的系统上可能存在阻止数据发送或接收的某些东西,或者您的网络上存在某些东西导致了这种情况。您的 OpenSSH 版本字符串看起来像是在 macOS 上,因此您应该检查防火墙配置。如果您在系统上安装了防病毒软件,请将其删除,然后重新启动。某些网络会阻止 SSH,因此这也可能是问题所在。如果尝试ssh git@github.com没有挂起,那么这可能是因为您的网络破坏了 IPv6 支持或破坏了路径 MTU 发现,在这种情况下,您应该检查您的路由器。您可以从另一个网络尝试(如果可能的话)并查看是否可以解决问题,在这种情况下,您知道它在您的网络上。

这里有很多潜在的问题,不可能一一列举。绝对不会有帮助的是更改http.postBuffer,因为这对 SSH 根本没有影响,只会影响服务器或代理已破坏 HTTP/1.1 支持的 HTTPS 连接。除非您知道自己需要它,否则不应设置它,因为它会导致每个 HTTPS 推送操作(无论多么小)分配全部内存,因此几乎在每种情况下,它都没有任何好处,只会浪费大量内存.

您也可以尝试切换到 HTTPS URL。有时由于某种原因效果更好。


推荐阅读