0%

Git代理配置及常见错误解决办法


作者: 耗子007


配置代理

1
2
3
git config –global http.proxy http://name:password@proxyhk.huawei.com:8080

git config –global https.proxy http://name:password@proxyhk.huawei.com:8080

比如这种错误的时候fatal: unable to access ‘https://github.com/kubernetes/kubernetes.git/’: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

1
2
3
git config –global http.sslverify false (解决证书验证问题)

git config –global https.sslverify false

注:不过这样并没有解决你证书的问题,只是跳过了而已。

Ubuntu在clone大的项目异常

可能会出下面的错误:

1
2
error: gnutls_handshake() failed: A TLS packet with unexpected length was received. while accessing …
fatal: HTTP request failed

这就需要你自己重新编译安装git了。

1
2
3
4
5
6
7
sudo apt-get install build-essential fakeroot dpkg-dev libcurl4-openssl-dev
sudo apt-get build-dep git
mkdir ~/git-openssl
cd ~/git-openssl
apt-get source git
dpkg-source -x git_1.7.9.5-1.dsc
cd git-1.7.9.5

修改“debian/control”文件,把所有的“libcurl4-gnutls-dev” 替换成“libcurl4-openssl-dev”

1
sudo dpkg-buildpackage -rfakeroot -b

安装对应的版本:

1
2
3
i386: sudo dpkg -i ../git_1.7.9.5-1_i386.deb

x86_64: sudo dpkg -i ../git_1.7.9.5-1_amd64.deb

注:git版本号,注意修改为你下载的对应版本号

参考文章:

http://askubuntu.com/questions/186847/error-gnutls-handshake-failed-when-connecting-to-https-servers/187199#187199