centos 安装git

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

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

2、下载

      1.1、进入到要下载的目录:cd /usr/local

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

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

     tar -xzvf soft git-2.19.2.tar.gz 

4、安装

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

     4.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 configure,再次出现错误,错误如下:

              GIT_VERSION = 2.19.2

              GEN configure

              bin/sh:autoconf:未找到命令

              make:***[configure]错误127

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

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

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

     4.5、进行安装,执行 make install

5、配置Git环境变量

     vi /etc/profile

     在文件尾添加
     export GIT_HOME=/usr/local/git
     export PATH=$PATH:$GIT_HOME/bin

6、检查版本:git --version

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

你可能感兴趣的:(运维)