致命:无法访问 'https://xxxx.git/':服务器证书验证失败。 CA文件:/etc/ssl/certs/ca-certificates.crt CRL文件:none

fatal: unable to access 'https://xxxx.git/': server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

我在云端使用 jupyter 笔记本,我想将我的 jupyter 笔记本推送到 gitlab。

我运行文件夹中有以下命令:

git init
git remote add origin https://xxx.git
git add .
git commit -m "first commit"
git push -u origin master

在最后一个命令之后,我得到了错误:

error: src refspec master does not match any.

所以我运行

git show-ref

这显示了三个参考

refs/heads/main

refs/remotes/origin/HEAD

refs/remotes/origin/main

正在尝试

git push origin HEAD:master

给出证书验证失败的错误。我做错了什么?

可能您在托管 GitLab 实例的服务器中没有受信任的 TLS1 证书。

我个人建议您使用受信任的证书,因为来自 Let's Encrypt 的证书是完全免费的,但无论如何您都可以禁用 TLS1 验证单个命令:

git -c http.sslVerify=false push origin -u

或者(不要这样做并使用受信任的证书)对所有存储库完全禁用它:

git config --global http.sslVerify false

*1:TLS 是 SSL 的新替代品。

Transport Layer Security (TLS), the successor of the now-deprecated Secure Sockets Layer (SSL), is a cryptographic protocol designed to provide communications security over a computer network.

- Wikipedia, Transport Layer Security link