git最新版安装

  31 Mar 2018


git 最新版本安装

// 删除老版本git
git -y remove git

// 安装依赖
yum -y groupinstall Development tools
yum install gcc perl-ExtUtils-MakeMaker

// 编译安装libiconv库
// http://www.gnu.org/software/libiconv/
tar zxvf libiconv-1.14.tar.gz
./configure --prefix=/usr/local
make && make install

// 如找不到libiconv.so.2 :
ln -s /usr/local/lib/libiconv.so.2 /usr/lib64/libiconv.so.2

// 下载git最新安装包
wget https://www.kernel.org/pub/software/scm/git/git-2.16.2.tar.gz

tar -xvf git-2.16.2.tar.gz
cd git-2.16.2

./configure --without-iconv
make CFLAGS=-liconv prefix=/usr/local/git all
make CFLAGS=-liconv prefix=/usr/local/git install

// 将git加入环境变量
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

// 或
ln -s /usr/local/git/bin/git /usr/local/bin/git

// 查看git版本
git version