Git Error: failed: The TLS connection was non-properly terminated

Tencent virtual machine doesn’t know why it can’t git clone, and an error is reported:

fatal: unable to access '': gnutls_handshake() failed: The TLS connection was non-properly terminated.
plugin ruby not found in repository

After checking, you need to use libcurl4 OpenSSL dev to replace gnutls to compile GIT.

sudo apt-get install build-essential fakeroot dpkg-dev
mkdir ~/git-openssl
cd ~/git-openssl
sudo apt-get source git
sudo apt-get build-dep git

If there is an error that the source code cannot be found, use the command sudo vim /etc/apt/sources.list to open the file and uncomment the line with deb_src, save and run sudo apt update, and then execute the last command above.

sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x git_2.17.1-1ubuntu0.9.dsc
cd git_2.17.1 # Actual version may differ

Then edit the Debian/control file and use the command sudo VIM deebian/control to change all libcurl4 gnutls dev to libcurl4 OpenSSL dev. (I only met one libcurl4 gnutls dev here)
then run the command:

# This step will take a long time, wait patiently
sudo dpkg-buildpackage -rfakeroot -b

sudo dpkg -i git_2.17.1-1ubuntu0.9_amd64.deb

That’s it. Just git again

+ git clone /root/.asdf --depth 1
Cloning into '/root/.asdf'...
+ echo -e '\n. $HOME/.asdf/'
+ echo -e '\n. $HOME/.asdf/completions/asdf.bash'
+ echo -e 'legacy_version_file = yes'
+ asdf plugin-add ruby
initializing plugin repository...Cloning into '/root/.asdf/repository'...


I did it again in the afternoon. There was still the same problem. Finally, the reset agent solved it perfectly

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

Read More: