git clone error: gnutls_handshake() failed: An unexpected TLS packet was received

Finally found the answer. It seems that I have to do:

git config --global http.proxy http://<my_proxy>:<my_port>
git config --global https.proxy https://<my_proxy>:<my_port>

Spent quick some time on this but luckily it works in the end. I thought this would be hard to fix but it turns out to be some commands that I never did before on Ubuntu 16.04.


Might be issue with gnutls Package. we have to compile a git Package with openssl instead of gnutls. Follow the below steps,

sudo apt-get install -y build-essential fakeroot dpkg-dev
sudo apt-get -y build-dep git
sudo apt-get install -y libcurl4-openssl-dev

mkdir git-openssl
cd git-openssl
apt-get source git
cd git-*
sed -i -e 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/g' 
./debian/control
sed -i -- '/TEST\s*=\s*test/d' ./debian/rules
sudo dpkg-buildpackage -rfakeroot -b
sudo dpkg -i git_2.7.4-0ubuntu1.6_arm64.deb

#CleanUp
cd ../../
sudo rm -rf git-openssl

You can follow This Bog or You can find simple script here to do that