You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

Git拉取/推送失败:无法访问HTTPS,报SSL协议版本错误求助

Fixing Git's "SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version" Error with GitHub

Hey there, let's get this Git connection issue sorted out. That error message tells me your local Git setup is trying to use an outdated TLS protocol version that GitHub no longer supports—they dropped support for TLS 1.0 and 1.1 a while back, so we need to make sure your tools are using modern TLS versions (like 1.2 or 1.3).

Here's step-by-step what to do:

1. Check your Git version first

Old versions of Git default to older TLS protocols. Run this command in your terminal to see what you're working with:

git --version

If your version is older than 2.14.0, this is almost certainly the root cause. GitHub started enforcing TLS 1.2+ around 2018, and Git 2.14.0 was the first version to default to TLS 1.2 for HTTPS connections.

2. Upgrade Git to the latest version

Upgrading is the most reliable fix. Here's how for different systems:

  • Windows: Download the latest Git installer from the official distribution and run it (it will overwrite your existing installation without losing your settings).
  • macOS: If you use Homebrew, run brew upgrade git. If you rely on Xcode's command line tools, update Xcode or run xcode-select --install to get the latest version.
  • Linux (Debian/Ubuntu): Run sudo apt update && sudo apt install git to pull the latest package.
  • Linux (CentOS/RHEL): Use sudo dnf update git (for newer systems) or sudo yum update git.

3. Manually force Git to use TLS 1.2 (if you can't upgrade right now)

If upgrading isn't an option temporarily, you can configure Git to explicitly use TLS 1.2:

git config --global http.sslVersion tlsv1.2

To verify the setting was applied, run:

git config --global --get http.sslVersion

You should see tlsv1.2 printed out.

4. Check your system's SSL library (if issues persist)

Git relies on your system's OpenSSL library for SSL connections. Run this to check your OpenSSL version:

openssl version

If you have a version older than 1.0.1g, it doesn't support TLS 1.2. You'll need to upgrade OpenSSL using your system's package manager (the same way you upgraded Git). Note that Windows versions of Git come with their own bundled OpenSSL, so this is mostly a concern for Linux/macOS users.

5. Rule out proxy interference

Sometimes proxies (corporate or third-party) can block or downgrade TLS connections. Try temporarily disabling any proxy you're using, or clear Git's proxy settings with:

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

Then try running git pull again to see if that fixes it.

Once you've tried these steps, your Git should be able to connect to GitHub without that SSL error. Let me know if you hit any snags!

内容的提问来源于stack exchange,提问作者Shayan Nahrvar

火山引擎 最新活动