由于在使用码云过程中的错误,导致必须安装最新版的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