centos7用yum安装git2.x的方法

字号+ 编辑: 种花家 修订: 种花家 来源: 网络转载 2023-09-11 我要说两句(0)

centos的默认yum源是没有git 2.x的版本的, 正常都是1.8, 这样有些命令就会失灵提示找不到。小编告诉你怎么解决。

不明原因, ius已经拉胯, 不支持git2 -- 2023.04.03

用ius的发行库来搞, 粘贴复制命令如下:

yum -y install epel-release

cat > /etc/yum.repos.d/ius.repo <<-EOF
[ius]
name = IUS for Enterprise Linux 7 - $basearch
baseurl = https://repo.ius.io/7/$basearch/
enabled = 1
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
[ius-debuginfo]
name = IUS for Enterprise Linux 7 - $basearch - Debug
baseurl = https://repo.ius.io/7/$basearch/debug/
enabled = 0
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
[ius-source]
name = IUS for Enterprise Linux 7 - Source
baseurl = https://repo.ius.io/7/src/
enabled = 0
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
EOF

有时候会发现$basearch失效, 导致后续的404 bug.

那么只能把上述命令改为, 假设你服务器架构是x86_64的:

cat > /etc/yum.repos.d/ius.repo <<-EOF
[ius]
name = IUS for Enterprise Linux 7 - x86_64
baseurl = https://repo.ius.io/7/x86_64/
enabled = 1
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
[ius-debuginfo]
name = IUS for Enterprise Linux 7 - x86_64 - Debug
baseurl = https://repo.ius.io/7/x86_64/debug/
enabled = 0
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
[ius-source]
name = IUS for Enterprise Linux 7 - Source
baseurl = https://repo.ius.io/7/src/
enabled = 0
repo_gpgcheck = 0
gpgcheck = 1
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-IUS-7
EOF

我想知道服务器架构怎么看?

rpm -qi centos-release

搜索yum现有库里的git 2.x版本安装包名

yum search git

看控制台返回啥包名?

根据包名安装

yum install -y gitxxxx

完工

第二种方法: 手动安装git

官方下载(举例版本号是2.40.0):

有时候github官网的鬼子会脑抽去改地址, 这个时候需要你找找, 或者在下方留言纠错。

https://github.com/git/git/releases/tag/v2.40.0

下载里面的source code包, 把.tar.gz的down下来

放到服务器上解压:

tar -zxvf git-2.40.0.tar.gz

安装依赖包:

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

升级 解决 SSL connect error

yum update -y nss curl libcurl
mkdir -p /usr/local/git
make prefix=/usr/local/git all
make prefix=/usr/local/git install

编辑profile:

vi /etc/profile

在里面写入:

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

保存文件, 让profile立即生效:

source /etc/profile

 

阅完此文,您的感想如何?
  • 有用

    0

  • 没用

    0

  • 开心

    0

  • 愤怒

    0

  • 可怜

    0

1.如文章侵犯了您的版权,请发邮件通知本站,该文章将在24小时内删除;
2.本站标注原创的文章,转发时烦请注明来源;
3.交流群: PHP+JS聊天群

相关课文
  • Linux系统下word文档转成pdf的办法

  • ubuntu和debian安装nginx或者tengine报错, 找不到pcre依赖库的解决办法

  • linux终端下借助awk命令查询筛出网站access.log日志里的统计信息

  • 常见的web中间件请求返回状态码

我要说说
网上宾友点评