Centos 8 安装Git 2.9.5(编译安装)与yum安装(更新时间2019/12/13 14:46)

1. 下载git, 下载地址, 我下载的是git-2.9.5.tar.gz

    [root@localhost cocosum.cn]# ls
    git-2.9.5.tar.gz
2. 解压

    [root@localhost cocosum.cn]# sudo zxvf git-2.9.5

3. 安装依赖

    [root@localhost cocosum.cn]# yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker    

4. 编译

    [root@localhost cocosum.cn]# cd git-2.9.5/
    [root@localhost git-2.9.5]# 
    [root@localhost git-2.9.5]# make prefix=/usr/local/git all

5. 安装

    [root@localhost git-2.9.5]# make prefix=/usr/local/git install

6. 配置环境变量

    [root@localhost git-2.9.5]#  vi /etc/profile

    加入下面环境变量:

    export PATH=$PATH:/usr/local/git/bin

7. 使配置生效

    [root@localhost git-2.9.5]# source /etc/profile

8. 检查Git版本

    [root@localhost git-2.9.5]# git --version
    git version 2.9.5

上面参考原文: 

其实可以不一定要安装在/usr/local/ 下面,也可以自己定义,
我自己安装在/opt/git-2.9.5/install/, 编译的时候把路径改掉就行了(安装同编译路径),
这种自定义路径用git --version 无法获取。下面方式可以获取:

    我的编译路径和安装路径是:

    [root@localhost git-2.9.5]# ls /opt/git-2.9.5/install/git/
    bin  libexec  share

    查看我安装的git版本

    [root@localhost git-2.9.5]# /opt/git-2.9.5/install/git/bin/git --version
    git version 2.9.5

9. 卸载Git, 直接删除你安装的路径就OK了

   [root@localhost git-2.9.5]# cd /usr/local/
   [root@localhost local]# ls
   bin  etc  games  git  include  lib  lib64  libexec  sbin  share  src
   [root@localhost local]# rm -rf git
    

还有一种安装方式: yum 安装 

# 检查
[root@VM_0_3_centos ~]# git --vserion
-bash: git: command not found
[root@VM_0_3_centos ~]# yum -y install git
Loaded plugins: fastestmirror, langpacks
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
............
............
............
Installed:
  git.x86_64 0:1.8.3.1-20.el7                                                                                                                                                                            

Dependency Installed:
  perl-Git.noarch 0:1.8.3.1-20.el7                                                                                                                                                                       

Complete!
[root@VM_0_3_centos ~]# git --version
git version 1.8.3.1
[root@VM_0_3_centos ~]# 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章