Linux安装git

采用yum安装的git版本是 1.x,目前git版本已更新至2.x,故采用自行下载包安装

1. 下载安装包

https://github.com/git/git/tags

传输至 云服务器

2. 解压

1
2
3
4
[root@centos7 ~]# cd /app/
[root@centos7 app]# mkdir git
[root@centos7 app]# cd git
[root@centos7 git]# tar -zxvf git-2.37.1.tar.gz

不安装会没有remote-http* 相关执行文件

1
[root@centos7 git]# yum install libcurl-devel && yum install curl-devel 

进入目录

1
2
3
4
5
[root@centos7 git]# cd git-2.37.1
[root@centos7 git-2.37.1]# make configure
GIT_VERSION = 2.37.1
GEN configure
/bin/sh: autoconf: 未找到命令

安装automake,autoconf

1
2
3
4
5
dnf search autoconf
dnf install autoconf2.7x.noarch

dnf search automake
dnf install automake.noarch

继续安装

1
2
3
[root@centos7 git-2.37.1]# ./configure --prefix=/usr/local/git
[root@centos7 git-2.37.1]# make profix=/usr/local/git
[root@centos7 git-2.37.1]# make install

3. 关闭原有git

1
2
3
[root@centos7 git-2.37.1]# cd /
[root@centos7 /]# rpm -qa | grep git
[root@centos7 /]# rpm -e git --nodeps

–nodeps 不查询依赖关系

4. 配置文件

1
2
3
4
5
6
7
8
9
[root@centos7 profile.d]# cd ~
[root@centos7 ~]# vi .bash_profile

export PATH=$PATH:/usr/local/git/bin

[root@centos7 ~]# source ~/.bash_profile
[root@centos7 ~]#
[root@centos7 ~]# git --version
git version 2.37.1
本文结束  感谢您的阅读
  • 本文作者: Wang Ting
  • 本文链接: /zh-CN/2021/08/01/Linux安装git/
  • 发布时间: 2021-08-01 21:10
  • 更新时间: 2023-04-15 16:15
  • 版权声明: 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!