文章更新
- 20170330-初次成文
为什么会有这篇文章
将低版本git升级到较高版本
使用编译方式升级
移除低版本git
yum remove git*
下载新版git源代码
Go编译过程中要求高版本的git,而yum源里面默认只有1.7.1版本。
#原版kernel.org国内访问过慢,替换为中科大源
wget http://mirrors.ustc.edu.cn/kernel.org/software/scm/git/git-2.9.3.tar.gz
#wget https://coding.net/u/sfantree/p/self_use_OSS/git/raw/master/ngrok/git-2.6.0.tar.gz
#wget https://coding.net/u/sfantree/p/self_use_OSS/git/raw/master/ngrok/git-2.9.3.tar.gz
tar zxvf git-2.9.3.tar.gz
cd git-2.9.3
./configure --prefix=/usr/local/git-2.9.3
make
make install
编译错误
如果在编译过程中遇到错误:
LINK git-credential-store
libgit.a(utf8.o): In function `reencode_string_iconv’:
/opt/git-master/utf8.c:530: undefined reference to `libiconv’
libgit.a(utf8.o): In function `reencode_string_len’:
/opt/git-master/utf8.c:569: undefined reference to `libiconv_open’
/opt/git-master/utf8.c:588: undefined reference to `libiconv_close’
/opt/git-master/utf8.c:582: undefined reference to `libiconv_open’
collect2: ld 返回 1
make: *** [git-credential-store] 错误 1
如果没遇到,请直接跳过这一章节。
解决办法:
cd /usr/local/src/
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 && sudo make install
然后回到git继续编译:
make configure
./configure --prefix=/usr/local -with-iconv=/usr/local/libiconv
make
make install
取代yum安装的低版本git
ln -s /usr/local/git-2.9.3/bin/* /usr/bin/
检查git版本
git --version