Centos7安装git

git

Posted by Gary Kwok on May 14, 2020

前言

有些版本的centos7是自带git的,但是版本比较低,需要更换为新的版本。 这里采用源码安装的方式

1. 删除原来的git(若有)

yum remove git

2. 安装git依赖包

yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker

3.下载编译安装git源码

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

cd /datas/software/ 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 export PATH=$PATH:/usr/local/git/bin make && make install

4.配置环境变量

vi /etc/profile 最后一行加入 export PATH=$PATH:/usr/local/git/bin source /etc/profile

5.验证安装

git –version