因为CentOS 7的yum自带的版本才1.8.3.1,而vs code要2.x以上,所以只能从源码构建
命令:
$ wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.9.5.tar.gz
$ tar -zxvf git-2.9.5.tar.gz
$ cd git-2.9.5/
# 将所有内容移动到/usr/local下,也可以使用移动命令将git-2.9.5移动到/usr/local,后面就可以直接make ...
make prefix=/usr/local all
# 编译源码安装,如果make没有安装需要先yum install make
sudo make prefix=/usr/local install
# 安装成功关闭终端重新打开,查看下版本号
git --version
其中在make prefix=/usr/local all 这步历经坎坷:
错误1
CC credential-store.o
/bin/sh: cc: command not found
make: *** [credential-store.o] 错误 127
报这个错误的原因是没有安装gcc,需要sudo yum install gcc
错误2
CC credential-store.o
In file included from cache.h:4:0,
from credential-store.c:1:
git-compat-util.h:280:25: 致命错误:openssl/ssl.h:没有那个文件或目录
#include <openssl/ssl.h>
^
编译中断。
make: *** [credential-store.o] 错误 1
报这个错误的原因是没有安装libssl-dev,需要sudo yum install openssl-devel
错误3
tp.h:6:23: 致命错误:curl/curl.h:没有那个文件或目录
#include <curl/curl.h>
^
编译中断。
make: *** [http.o] 错误 1
报这个错误的原因是缺少libcurl-dev or libcurl-devel,需要sudo yum install libcurl-dev libcurl-devel
错误4:使用make prefix=/usr/local all时报错:
http-push.c:18:19: 致命错误:expat.h:没有那个文件或目录
#include <expat.h>
^
编译中断。
make: *** [http-push.o] 错误 1
报这个错误的原因是缺少expat,需要sudo yum install expat-devel
错误5
/usr/bin/perl Makefile.PL PREFIX='/usr/local' INSTALL_BASE='' --localedir='/usr/local/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.
make[1]: *** [perl.mak] 错误 2
make: *** [perl/perl.mak] 错误 2
报这个错误的原因是缺少对应的包,需要sudo yum install perl-ExtUtils-MakeMaker