跳转至

🛢️ Git常见错误

1. 网络错误

【问题复现】

# 代理ON:
fatal: unable to access 'https://github.com/yiyifengheju/ONAV.git/': Error in the HTTP2 framing layer
# 代理OFF:
fatal: unable to access 'https://github.com/yiyifengheju/ONAV.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.

【解决方法】

sudo apt-get update
sudo apt-get install gnutls-bin
git config --global http.sslVerify false
git config --global http.postBuffer 1048576000

2. RPC错误

【问题复现】

error: RPC failed; curl 16 Error in the HTTP2 framing layer
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly

【解决方法】强制将git设置为HTTP 1.1:

git config --global http.version HTTP/1.1

恢复方法:

git config --global http.version HTTP/2

3. WSL代理问题

【问题复现】打开WSL时显示:

wsl: 检测到 localhost 代理配置,但未镜像到 WSL。NAT 模式下的 WSL 不支持 localhost 代理。

【解决方法】在Windows中的C:\Users\$Username$\目录下创建一个.wslconfig文件,然后在文件中写入如下内容:

[experimental]
autoMemoryReclaim=gradual  
networkingMode=mirrored
dnsTunneling=true
firewall=true
autoProxy=true

4. 每次git都需要输入用户名和密码

【问题复现】如题

【解决方法】执行下述命令后,再执行git pullgit push,输入用户名密码,以后就不需要每次都输入了。

git config --global credential.helper store

5. 报ssh拒绝连接,无法git clone

ssh -T [email protected]
# ssh: connect to host github.com port 22: Connection refused

解决方法:新建文件~/.ssh/config,写入:

Host github.com
Hostname ssh.github.com
port 443