CentOS升级git版本

新逸网络 811 0

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、笔者测试环境为

CentOS升级git版本

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]# rpm -e --nodeps 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

#git 新版本安装后的问题

  • 报错,SSL连接错误
    Centos系统此时更新NSS即可:
    yum -y update nss
  • 报错2,无法找到原git路径的错误
    解决方法:
    ln -s /usr/local/git/bin/git /usr/bin/git

本文链接:https://www.xinac.com/article/235.htm

原文链接:https://blog.xinac.cn/archives/git-update

参考文章:

  1. Centos下升级git版本
  2. 一次Git的软件版本升级

发表评论 取消回复
表情 图片 链接 代码

分享