1、安装 git
代码如下 | |
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel |
2、下载git源码(http://code.google.com/p/git-core)
代码如下 | |
cd /usr/local/src wget https://git-core.googlecode.com/files/git-1.8.5.tar.gz tar -zvxf git-1.8.5 cd git-1.8.5 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继续编译:
代码如下 | |
cd /usr/local/src/git-1.8.5 make configure ./configure –-prefix=/usr/local –with-iconv=/usr/local/libiconv make make install |
此时,git应该编译安装成功了,可以测试下:
代码如下 | |
cd /usr/local/bin ./git –version git version 1.8.5 |
可能你会发现为什么直接在命令行输入git却提示无效呢,这里还需要做点设置,编辑/etc/profile, 将/usr/local/bin加入到系统路径:
代码如下 | |
export PATH=$PATH:/usr/local/bin |
保存退出,再刷新一下系统路径:
代码如下 | |
source /etc/profile |
在终端直接输入 git –-version
如能正确显示版本,git version 1.8.5,则大功告成。