前言
CentOS 7安装Git,默认安装版本为1.8.3.1,若要安装Git最新版本,需要下载Git安装包。
一、使用yum安装Git
1. 安装Git
yum install git
2. 查看git版本
[root@localhost ~]#git --version
git version 1.8.3.1
3. 移除git
yum remove git
二、源码包安装Git
1.安装依赖
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
yum install gcc-c++ perl-ExtUtils-MakeMaker
2.下载源码包
git源码包官方下载地址
https://mirrors.edge.kernel.org/pub/software/scm/git/
我下载的是git-2.39.0.tar.gz
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.39.0.tar.gz
3.解压源码包
tar -zxvf git-2.39.0.tar.gz
4.Git安装
cd git-2.39.0
./configure
make && make install
5.安装完查看Git版本
[root@localhost ~]# git version
git version 2.39.0
总结
以上是CentOS 7安装Git的内容,可使用yum和源码两种方式安装,yum默认安装的是1.8.3.1版本,源码可以选择自己需要的git版本安装。