centos6.5安装git 2.X版本

  • baagee 发布于 2016-10-05 22:22:34
  • 分类:Git
  • 1119 人围观
  • 0 人喜欢
网上找了好多教程,都没成功,总是出现各种问题,最后结合前几次教训,总结一下,成功了:

------------------------方法1--------------------------

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install  gcc perl-ExtUtils-MakeMaker

#卸载Centos自带的git1.7.1
#通过git –version查看系统带的版本,Cento6.5应该自带的是git版本是1.7.1
yum remove git

#下载git2.1.2并将git添加到环境变量中
#下载git最新版本
cd /usr/src
wget https://www.kernel.org/pub/software/scm/git/git-2.1.2.tar.gz
tar xzf git-2.1.2.tar.gz

#安装git并添加到环境变量中
cd git-2.1.2
make prefix=/usr/local/git all
make prefix=/usr/local/git 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继续编译:
成功时:

然后执行:
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/bashrc
source /etc/bashrc

然后查看版本号:git --version

-------------------方法2和方法1很像--------------------------

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
wget https://github.com/git/git/archive/v2.2.0.tar.gz
tar zxvf git-2.2.0.tar.gz
cd git-2.2.0
make prefix=/usr/local all
ake prefix=/usr/local install  #root用户运行

如果编译时提示错误:

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
git --version

这样就安装个完成了

转载请说明出处:baagee博客 » centos6.5安装git 2.X版本
标签: git centos

评论

点击图片切换
还没有评论,快来抢沙发吧!