gnutls_handshake() failed: Error in the pull function.

新装Ubuntu遇到git拉取问题?轻松修复:禁用全局代理后,gitconfig设置解除。确保顺利克隆代码。

新安装的镜像Ubuntu 16.04 LTS 拉取git库时报错,gnutls_handshake() failed: Error in the pull function.

执行下面操作后可以正常拉取git上的库了

#取消代理
git config --global --unset http.https://github.com.proxy

在 Linux 系统中,`git pull` 时出现 `gnutls_handshake() failed` 错误通常是由于网络问题、SSL/TLS 配置问题或服务器端问题导致的。以下是一些可能的解决办法: #### 检查网络连接 确保网络连接正常,可以尝试使用 `ping` 命令测试与 Git 服务器的连通性,例如: ```bash ping github.com ``` #### 检查 SSL 证书 有时候证书验证问题会导致该错误,可以尝试临时禁用 SSL 证书验证,但这只是临时解决方案,不建议长期使用: ```bash git config --global http.sslVerify false ``` 使用完后,建议恢复 SSL 证书验证: ```bash git config --global http.sslVerify true ``` #### 更新系统和 Git 确保系统和 Git 是最新版本,可以使用以下命令更新系统: ```bash # 对于基于 Debian 或 Ubuntu 的系统 sudo apt update sudo apt upgrade # 对于基于 Red Hat 或 CentOS 的系统 sudo yum update ``` 更新 Git 到最新版本,根据系统不同使用不同的包管理器进行更新。 #### 配置代理 如果使用了代理,确保代理配置正确。可以使用以下命令配置代理: ```bash git config --global http.proxy http://proxy.example.com:port git config --global https.proxy http://proxy.example.com:port ``` 若使用的是 socks5 代理,可使用如下命令: ```bash git config --global http.proxy socks5://127.0.0.1:port git config --global https.proxy socks5://127.0.0.1:port ``` 若要取消代理配置,可使用以下命令: ```bash git config --global --unset http.proxy git config --global --unset https.proxy ``` #### 手动更新 CA 证书 可以手动更新 CA 证书,确保系统有最新的证书: ```bash # 对于基于 Debian 或 Ubuntu 的系统 sudo apt install ca-certificates # 对于基于 Red Hat 或 CentOS 的系统 sudo yum install ca-certificates ``` #### 更改 Git 协议 如果使用的是 HTTPS 协议,可以尝试使用 SSH 协议。首先需要生成 SSH 密钥并添加到 Git 服务器: ```bash ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ``` 按照提示完成密钥生成后,将 `~/.ssh/id_rsa.pub` 文件中的内容添加到 Git 服务器的 SSH 密钥设置中。然后将远程仓库的 URL 从 HTTPS 改为 SSH,例如: ```bash git remote set-url origin git@github.com:username/repo.git ```
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值