linux可以通过yum install git 来进行快捷安装,但是只能安装1.7版本,不能满足github和一些git网站的需求,所以需要下载更高版本,而更高版本只提供了源码,所以下载下来要先进行编译才能使用。
1.准备工作,安装依赖包。
yum install zlib-devel
yum install openssl-devel
yum install perl
yum install cpio
yum install expat-devel
yum install gettext-devel
yum install autoconf
2.下载git源码
wget https://www.kernel.org/pub/software/scm/git/git-2.8.3.tar.gz
解压git安装包
tar -zxvf git-2.8.3.tar.gz
cd git-2.8.3
3.编译安装git,将其安装在/usr/local/git/目录下
make prefix=/usr/local/git all
make prefix=/usr/local/git install
这里有可以会报错:
1.usr/bin/perl Makefile.PL PREFIX='/usr/local/git' INSTALL_BASE='' --localedir='/usr/local/git/share/locale'
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.
解决方法:
安装依赖包:yum install perl-ExtUtils-MakeMaker package.
然后再重新编译安装git:
make prefix=/usr/local/git all
make prefix=/usr/local/git install
2.CC credential-store.o
/bin/sh: cc: command not found
make: *** [credential-store.o] 错误 127
解决方法:
报这个错误的原因是没有安装gcc,需要yum install gcc
4.配置环境变量
进入环境变量配置文件:vim /etc/profile
PATH里添加git的指定路径:我的路径是,/usr/local/git/bin
source /etc/profile:这个命令是让修改的文件生效
完了之后查看git是否安装成功:git --version
网友评论