Git不能更新以及提交代码,提示链接超时,本地凭证无问题

发布于:2025-06-14 ⋅ 阅读:(23) ⋅ 点赞:(0)

1、pull时打印日志

GIT_TRACE=1 GIT_CURL_VERBOSE=1 git pull

输出日志:

$ GIT_TRACE=1 GIT_CURL_VERBOSE=1 git pull
14:34:19.189472 exec-cmd.c:237          trace: resolved executable dir: D:/LifeApp/Git/mingw64/bin
14:34:19.192457 git.c:460               trace: built-in: git pull
14:34:19.194450 run-command.c:654       trace: run_command: git fetch --update-head-ok
14:34:19.208970 exec-cmd.c:237          trace: resolved executable dir: D:/LifeApp/Git/mingw64/libexec/git-core
14:34:19.211936 git.c:460               trace: built-in: git fetch --update-head-ok
14:34:19.215925 run-command.c:654       trace: run_command: GIT_DIR=.git git remote-https origin https://gitee.com/servers.git
14:34:19.230919 exec-cmd.c:237          trace: resolved executable dir: D:/LifeApp/Git/mingw64/libexec/git-core
14:34:19.232880 git.c:749               trace: exec: git-remote-https origin https://gitee.com/servers.git
14:34:19.232880 run-command.c:654       trace: run_command: git-remote-https origin https://gitee.com/servers.git
14:34:19.250833 exec-cmd.c:237          trace: resolved executable dir: D:/LifeApp/Git/mingw64/libexec/git-core
14:34:19.259843 http.c:703              == Info: Couldn't find host gitee.com in the (nil) file; using defaults
14:34:19.279609 http.c:703              == Info:   Trying 181.76.199.13:443...
14:34:19.321782 http.c:703              == Info: Connected to gitee.com (181.76.199.13) port 443 (#0)
14:34:19.322788 http.c:703              == Info: ALPN: offers h2
14:34:19.322788 http.c:703              == Info: ALPN: offers http/1.1
14:34:19.337779 http.c:703              == Info:  CAfile: D:/LifeApp/Git/mingw64/ssl/certs/ca-bundle.crt
14:34:19.337779 http.c:703              == Info:  CApath: none
14:34:19.337779 http.c:703              == Info: TLSv1.3 (OUT), TLS handshake, Client hello (1):

从调试日志来看,Git 已经成功连接到 Gitee 服务器(Connected to gitee.com (181.76.199.13) port 443),但在 TLS 握手阶段(Client hello)之后卡住,没有进一步输出。这表明问题可能出在 SSL/TLS 认证 或 网络代理拦截 上。以下是针对性解决方案

1. 检查 Git 的 SSL 证书配置

(1) 确认证书路径是否正确

日志中显示 Git 使用的 CA 证书路径:

CAfile: D:/LifeApp/Git/mingw64/ssl/certs/ca-bundle.crt
  • 检查该文件是否存在:

    ls "D:/LifeApp/Git/mingw64/ssl/certs/ca-bundle.crt"
  • 如果文件丢失,重新安装 Git 或手动下载证书包。

(2) 临时关闭 SSL 验证(测试用)
git config --global http.sslVerify false
git pull

如果成功,说明是证书问题,需修复证书路径或更新证书:

git config --global http.sslVerify true  # 恢复验证

2. 排除代理干扰

(1) 检查是否启用了代理
git config --global --get http.proxy
git config --global --get https.proxy
  • 如果返回代理地址,清除代理设置:

    git config --global --unset http.proxy
    git config --global --unset https.proxy