首先,卸載舊git竟宋,centos 6.8 默認(rèn)git版本1.7.1
yum remove git -y
然后,按照下面的步驟按照新版2.11.0
(1)升級(jí)系統(tǒng)
$ yum update
(2)安裝依賴包
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
(3)下載Git源碼并解壓
$ wget https://www.kernel.org/pub/software/scm/git/git-2.11.0.tar.gz
$ tar -zxvf git-2.11.0.tar.gz
$ cd git-2.11.0
(4)編譯安裝
$ make prefix=/usr/local/git all
$ make prefix=/usr/local/git install
編譯安裝出錯(cuò)了泵喘,
libgit.a(utf8.o): Infunction`reencode_string_iconv‘:/root/git-2.9.0/utf8.c:463: undefined reference to `libiconv‘libgit.a(utf8.o): Infunction`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返回1make: *** [git-credential-store] 錯(cuò)誤1
這樣做:
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
make clean
$ make prefix=/usr/local/git all
$ make prefix=/usr/local/git install
(5)配置git環(huán)境變量
$ vim /etc/bashrc
在最后一行添加
export PATH=/usr/local/git/bin:$PATH
(6)驗(yàn)證是否安裝成功
$ source /etc/bashrc
$ git --version(提示版本號(hào)說(shuō)明安裝成功)
(7)基本配置
$ git config --global user.name 'username'
$ git config --global user.email 'useremail'