最近在Centos上搭建Golang的开发环境,想增强VIM的功能,安装一些Golang的开发插件,但是系统自带的Git版本太低了,无法正常拉取代码。于是就想升级一下GIt,发现安装了Git后就遇到了以下的情况了。
系统自带的Git版本为:
[root@nginx-web ~]# git version
git version 1.7.1
原因:使用系统自带的Git无法克隆到Github.com上的代码,出现以下错误提示;
[root@nginx-web ~]# git clone https://github.com/fatih/vim-go.git ~/.vim/pack/plugins/start/vim-go
Initialized empty Git repository in /root/.vim/pack/plugins/start/vim-go/.git/error: while accessing https://github.com/fatih/vim-go.git/info/refs
fatal: HTTP request failed
卸载旧版本的Git
yum remove git -y
要升级Git,首先要安装一些依赖包;
安装基本的依赖包
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel nss gcc perl-ExtUtils-MakeMaker -y
下载最新的git源码包:
https://mirrors.edge.kernel.org/pub/software/scm/git/
解压、编译安装:
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.xz
tar xf git-2.9.5.tar.xz
cd git-2.9.5
./configure --prefix=/usr/local/git
make && make install
配置环境变量:
export PATH=$PATH:/usr/local/git/bin
source /etc/profile
查看版本变化了
[root@nginx-web ~]# git version
git version 2.9.5
注意:
但是如果缺少了nss包的话,在拉取以https开头的URL地址时就会有以下的几个异常信息;
可以执行安装:
yum install nss -y
异常1:fatal: Unable to find remote helper for ‘https’
异常2:fatal: unable to access ‘https://github.com/fatih/vim-go.git/‘: SSL connect error