centos7安装高版本git教程

 目录

前言

一、git官方文档

二、手动安装

1. 卸载低版本

2. 下载解压

3. 编译源码

4. 验证结果

总结


前言

生产服务器安装的Linux为Centos7.9,默认使用yum安装git只能到1.8.3。因此打算升级一下git版本。

# 查看centos版本
$ cat  /etc/redhat-release
# CentOS Linux release 7.9.2009 (Core)

# 使用yum安装
$ yum install git
# git version 2.31.1

一、git官方文档

查看git官方文档,关于centos安装git的说明如下,官方建议使用源码编译安装。

Red Hat Enterprise Linux, Oracle Linux, CentOS, Scientific Linux, et al.

RHEL and derivatives typically ship older versions of git. You can download a tarball and build from source, or use a 3rd-party repository such as the IUS Community Project to obtain a more recent version of git.

二、手动安装

1. 卸载低版本

# 查看git版本
git --version

# 卸载
yum remove git

2. 下载解压

# 下载
wget https://www.kernel.org/pub/software/scm/git/git-2.31.1.tar.gz

# 解压
tar xzf git-2.31.1.tar.gz

3. 编译源码

# 进入源码目录
$ cd git-2.31.1

# 安装工具和依赖
$ yum install libcurl-devel
$ yum install expat-devel
$ yum install openssl-devel

# 编译
$ make prefix=/usr/local/git all
$ make prefix=/usr/local/git install

# 将git路径加入bashrc配置
$ echo "export PATH=$PATH:/usr/local/git/bin" >>/etc/bashrc

# 应用bashrc
$ source /etc/bashrc

4. 验证结果

$ git --version
# git version 2.31.1

总结

以上就是今天要讲的内容,本文仅仅简单介绍了centos7上手动安装高版本的git的方案

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值