安装环境:centos7.2
在centos下其实用yum进行安装是最方便,最省事的。
但是有些情况下默认安装的版本无法满足需要,那么请安装以下步骤安装。
1.下载git
https://www.kernel.org/pub/software/scm/git/
2.安装依赖
(1)yum install zlib、yum install zlib-devel
不安装编译make时会出现以下错误:
In file included from credential-store.c:1:
cache.h:21:18: warning: zlib.h: No such file or directory
In file included from credential-store.c:1:
cache.h:23: error: expected specifier-qualifier-list before ‘z_stream’
make: *** [credential-store.o] Error 1
(2)yum install perl-ExtUtils-Embed -y
不安装编译make install会出现以下错误:
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5
/usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl
/usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 3.
BEGIN failed--compilation aborted at Makefile.PL line 3.
PS:如果运行git的时,又提示:
/usr/bin/git 没有哪个文件或目录
原来git安装到/usr/local/bin/目录内了,而centos默认该目录没有在搜索目录内。
解决办法,建立一个软链接吧。
ln -s /usr/local/bin/git /usr/bin/git
(3)yum install curl-devel
3.编译安装
tar -zxvf git-2.9.2.tar.gz
./configure --prefix==指定安装目录
make && make install
4.环境变量配置
vim /etc/profile
export GIT_HOME=/usr/local/git
export PATH=PATH"
source /etc/profile
5.验证
git -version
whereis git(如果只出现git:那么参照2-(2)-PS进行软连接)
参考文章:
1.https://blog.csdn.net/zhezhebie/article/details/78035979
2.https://www.cnblogs.com/litifeng/p/5754746.html
3.https://www.cnblogs.com/gsliuruigang/p/7899803.html