准备工作:
CentOS 上的最新git版本也只有1.8.3,就想试着装上最新的版本,没想到差点玩脱,全当记录一次冒险经历
- Development tools 没装的要装上,不然GCC编译时会出错
1
| # yum -y groupinstall Development tools
|
下载git并安装
1 2 3
| # cd /usr/src # wget https://www.kernel.org/pub/software/scm/git/git-2.12.0.tar.gz # tar xzf git-2.12.0.tar.gz
|
安装注意事项:
1 2
| # cd git-2.12.0 # make prefix=/usr/local/git all
|
此时报错
1 2 3 4 5 6 7
| /usr/src/git-2.12.0/utf8.c:463:对‘libiconv’未定义的引用 libgit.a(utf8.o):在函数‘reencode_string_len’中: /usr/src/git-2.12.0/utf8.c:524:对‘libiconv_open’未定义的引用 /usr/src/git-2.12.0/utf8.c:535:对‘libiconv_close’未定义的引用 /usr/src/git-2.12.0/utf8.c:529:对‘libiconv_open’未定义的引用 collect2: 错误:ld 返回 1 make: *** [git-credential-store] 错误 1
|
原方案:
1 2
| # make prefix=/usr/local/git all # make prefix=/usr/local/git install
|
解决方案:
可替换为
1 2 3
| # ./configure --without-iconv # make CFLAGS=-liconv prefix=/usr/local/git all # make CFLAGS=-liconv prefix=/usr/local/git install
|
最后将git加入环境变量
1 2
| # echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc # source /etc/bashrc
|
大功告成!查看一下git的版本
1 2
| # git --version >> git version 2.12.0
|