CentOS7中安装Git

一、可以使用yum进行安装

1、安装git:yum install git 

2、查看yum源仓库Git信息:yum info git

3、安装依赖库:yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

                           yum install gcc-c++ perl-ExtUtils-MakeMaker

4、查看git版本,如果默认安装的版本过低,移除默认安装的git

      4.1、查看版本信息:git  --version

      4.2、移除默认安装的git:yum remove git

二、自行下载安装Git

       最新git源码下载地址:

       https://github.com/git/git/releases

       https://www.kernel.org/pub/software/scm/git/

1、下载

      1.1、进入到要下载的目录:cd soft

      1.2、用wegt命令进行下载:wget https://www.kernel.org/pub/software/scm/git/git-2.19.2.tar.gz

2、解压:此处解压到/usr/local目录下

     tar -xzvf soft git-2.19.2.tar.gz -C /usr/local

3、安装

     3.1、进入解压后的git目录:cd /usr/local/git-2.19.2

     3.2、执行make configure

              注意:执行此命令时,开始出错,错误如下:

              configure: Setting lib to 'lib' (the default)

              configure: Will try -pthread then -lpthread to enable POSIX Threads.

              configure: CHECKS for site configuration

              checking for gcc... no

              checking for cc... no

              checking for cl.exe... no

              configure: error: in `/opt/git-2.19.0':

              configure: error: no acceptable C compiler found in $PATH

              See `config.log' for more details  

              解决办法:通过yum providers gcc 和 yum providers cc 查询到c编译器没有安装,可通过执行yum -y install gcc安装gcc包及对应的依赖。

              再次执行make configuer,再次出现错误,错误如下:

              GIT_VERSION = 2.19.2

              GEN configure

              bin/sh:autoconf:未找到命令

              make:***[configure]错误127

              解决办法:通过yum providers autoconf 查询到没有安装autoconf,可通过执行yum -y install autoconf安装包及对应的依赖。 

     3.3、配置目录:./configure --prefix=/usr/local/git

     3.4、执行 make profix=/usr/local/git

     3.5、执行make insrtall进行安装

4、加入环境变量:echo "export PATH=$PATH:/usr/git/bin" >> /etc/profile

                               source /etc/profile   //使修改的文件生效

5、检查版本:git --version

      如果显示:git version 2.19.2 则证明安装成功!


 


 


 

猜你喜欢

转载自blog.csdn.net/hdn_kb/article/details/90696500
今日推荐