如何在CentOS上安装Git

aries 发表于 2014-12-11 1277 次浏览

1.安装编译git时需要的包

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

2.删除已有的git

yum remove git

3.下载git源码并安装

wget https://www.kernel.org/pub/software/scm/git/git-2.20.1.tar.gz
tar zxzf git-2.20.1.tar.gz
cd git-2.20.1
mkdir /usr/local/git
make prefix=/usr/local/git all  #注意:运行这段命令后,可以会出错,参考下面的解决办法~
make prefix=/usr/local/git install
echo "export PATH=$PATH:/usr/local/git/bin" >> /etc/profile
source /etc/profile

5.检查一下版本号

git --version
git version 2.20.1

6.错误的解决办法。

如生如下错误:

LINK git-credential-store

libgit.a(utf8.o): In function `reencode_string_iconv':

/home/chukong/gitsource/utf8.c:530: undefined reference to `libiconv'

libgit.a(utf8.o): In function `reencode_string_len':

/home/chukong/gitsource/utf8.c:569: undefined reference to `libiconv_open'

/home/chukong/gitsource/utf8.c:588: undefined reference to`libiconv_close'

/home/chukong/gitsource/utf8.c:582: undefined reference to `libiconv_open'

collect2: ld ?? 1

make: *** [git-credential-store] Error 1

说明链接时找不到libiconv。去官网下载一个:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
#解压,安装:
tar zxzf libiconv-1.14.tar.gz
cd libiconv-1.14
mkdir /usr/local/libiconv-1.14
./configure --prefix=/usr/local/libiconv-1.14
make && make install

然后再回到git-2.20.1的目录执行

make configure
./configure --prefix=/usr/local/git --with-iconv=/usr/local/libiconv-1.14
make && make install

即可编译成功

0条评论

如需评论,请填写表单。
换一个

记住我的信息