Centos系统下安装Git

git下载地址:https://mirrors.edge.kernel.org/pub/software/scm/git/

相关信息:

操作系统:Centos 8.2

Git:git-2.9.5.tar.gz

[root@VM-12-13-centos pkgs]# pwd
/usr/local/pkgs
[root@VM-12-13-centos pkgs]# ll
total 403368
-rw-r--r--  1 root  root    5928730 Jun  8 14:01 git-2.9.5.tar.gz

解压Git源码包

[root@VM-12-13-centos pkgs]# tar -zxvf git-2.9.5.tar.gz 

配置安装目录

[root@VM-12-13-centos pkgs]# cd git-2.9.5/
[root@VM-12-13-centos git-2.9.5]# ./configure --prefix=/usr/local/git
[root@VM-12-13-centos git-2.9.5]# make && make install

如果安装失败,控制台显示以下内容

BEGIN failed--compilation aborted at Makefile.PL line 3.
make[1]: *** [Makefile:83: perl.mak] Error 2
make: *** [Makefile:1800: perl/perl.mak] Error 2

则需要安装perl-devel,然后再重新安装

[root@VM-12-13-centos git-2.9.5]# yum install -y perl-devel
[root@VM-12-13-centos git-2.9.5]# make && make install

安装成功后,配置环境变量;编辑 ~/.bashrc 文件,在文件末尾增加  export PATH="/usr/local/git/bin:$PATH"

[root@VM-12-13-centos git-2.9.5]# vim ~/.bashrc 
[root@VM-12-13-centos git-2.9.5]# source ~/.bashrc 

最后查看是否安装成功

[root@VM-12-13-centos git-2.9.5]# git version
git version 2.9.5

 

posted @ 2022-06-08 14:31  狱婪  阅读(1493)  评论(0编辑  收藏  举报