linux centos7 安装最新版git 教程

由于在使用码云过程中的错误,导致必须安装最新版的git,所以记录下安装过程!

    1、查看已有git版本

    # git --version
    git version 1.7.1

    2、查看 yum 源仓库的 Git 信息

# yum info git

     

这里写图片描述

可以发现yum 源仓库里的 Git 版本并不是官网上的最新版本2.9.2,想要安装最新版本的的 Git,只能下载源码进行安装。

    3、卸载低版本git

# yum remove git

    4、依赖库安装

    # yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
    # yum install  gcc perl-ExtUtils-MakeMaker

    5、下载最新版git

# wget https://github.com/git/git/archive/v2.9.2.tar.gz

    6、解压到相应的目录

# tar zxf v2.9.2.tar.gz   (ps:目录名可能会出错,先查看目录名再解压)

    7、安装git

    # cd git-2.9.2
    # make prefix=/usr/local/git all
    # make prefix=/usr/local/git install

  编译时出现如下异常:

libgit.a(utf8.o): In function `reencode_string_iconv':
/root/git-2.9.0/utf8.c:463: undefined reference to `libiconv'
libgit.a(utf8.o): In function `reencode_string_len':
/root/git-2.9.0/utf8.c:502: undefined reference to `libiconv_open'
/root/git-2.9.0/utf8.c:521: undefined reference to `libiconv_close'
/root/git-2.9.0/utf8.c:515: undefined reference to `libiconv_open'
collect2: ld 返回 1
make: *** [git-credential-store] 错误 1

 下载并安装libiconv(http://ftp.gnu.org/pub/gnu/libiconv/

cd ..
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar -zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv  &&  make  && make install

 返回git在此编译安装

cd ../git-2.9.0
make clean
make configure
./configure --prefix=/usr/local --with-iconv=/usr/local/libiconv/
make install

    8、添加到环境变量

    # echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
    # source /etc/bashrc

    9、查看版本号

    # git --version
    git version 2.9.2
 

转载:https://blog.csdn.net/alisen169/article/details/81941524

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值