Centos下升级git版本
1、升级原因
在使用git pull、git push、git clone的时候,或者在使用jenkins发版的时候,可能会报类似如下的错误:
error: The requested URL returned error: 401 Unauthorized while accessing https://git.oschina.net/zemo/demo.git/info/refs
fatal: HTTP request failed
像centos7.5一般自带的git都是1.8.3.1版本的,比较老了,所以有时候需要升级一下git版本
2、笔者测试环境为
3、安装依赖软件
[root@localhost test1]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel asciidoc
[root@localhost test1]# yum install gcc perl-ExtUtils-MakeMaker
4、卸载系统自带的低版本git
[root@localhost test1]# git --version
[root@localhost test1]# yum remove git
5、编译安装最新的git版本
[root@localhost test1]# cd /usr/local/src/
[root@localhost test1]# wget https://www.kernel.org/pub/software/scm/git/git-2.15.1.tar.xz
[root@localhost test1]# tar -vxf git-2.15.1.tar.xz
[root@localhost test1]# cd git-2.15.1
[root@localhost test1]# make prefix=/usr/local/git all
[root@localhost test1]# make prefix=/usr/local/git install
[root@localhost test1]# echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
[root@localhost test1]# source /etc/profile
[root@localhost test1]# git --version