在 CentOS 7 上安装更新版本的 Git

Oli*_*ver 35 git centos7

我喜欢在我的 CentOS 7 服务器上启用 Git“推送部署”。目前我只能通过 yum 获得 Git 1.8.3.1。我需要更新的版本。

我必须从源代码构建它还是有任何我可以使用的存储库?我已经添加了EPELelrepo但 yum 仍然给我 Git 1.8.3.1。

los*_*jos 46

您可以使用此处此处Git 官方站点上提供的IUS 存储库( https://ius.io/ ) 。它包含预构建的二进制文件。x86_64

为此,请运行(以 root 身份):

yum install epel-release
yum remove git
rpm -U https://centos7.iuscommunity.org/ius-release.rpm
yum install git2u
Run Code Online (Sandbox Code Playgroud)

(如果您没有使用 CentOS,centos7可以替换为centos6rhel{6,7})。

注意:一些用户报告说没有更多的包叫做git2u. 您也可以尝试使用软件包git222git224在这种情况下。

另一种选择是使用另一个 RPM 存储库 ( i386& x86_64):

sudo yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm
sudo yum install git
Run Code Online (Sandbox Code Playgroud)

  • 绝对是我会使用的方法,因为您安装了维护良好的 RPM,而不是您创建的任何构建工具。 (4认同)
  • 看来新的设置ius的指令是:https://ius.io/setup。另外,不再有名为“git2u”的包了。新名称应该是“git224”:“yum install git224”对我有用。 (4认同)
  • 对我有用,但需要将 rpm -U https://centos7.iuscommunity.org/ius-release.rpm 替换为 yum install https://repo.ius.io/ius-release-el7 .rpm`` (4认同)
  • 请注意,使用 3rd 方存储库可能不安全。这是处理该问题的 [博客文章](https://linux-audit.com/missing-packages-do-not-trust-external-repositories/)。 (3认同)
  • 我在“Amazon Linux AMI”上收到“curl: (7) Failed to connect to centos7.iuscommunity.org port 443: Connection timed out” 有人知道如何解决吗? (2认同)

小智 15

从源代码构建非常简单。Digital Ocean 有一个关于在 CentOS 7 上从源代码构建 Git很好的指南。将生成的二进制文件放在 CentOS 7 系统(默认情况下,包含在 $PATH 中)的 /usr/local/bin/ 中,您就可以开始了。

当然,您更喜欢包/使用 repo,但是鉴于您的情况,我会毫不犹豫地自己构建它。

一般信息;推送部署是在Git 2.3.0中引入的。确保使用此版本或更高版本。


jdh*_*hao 14

CentOS 7 对我有用的是什么:

yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum remove git
yum install git236
Run Code Online (Sandbox Code Playgroud)

参考:

  • 截至 2022 年 6 月,最后一行应该是“yum install git236”。 (2认同)

Kir*_*rby 13

我对 CentOS 7.2 有这种方法:

rpm -U http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm \
    && yum install -y git
Run Code Online (Sandbox Code Playgroud)

目前我有2.10.0GIT 版本。

或者对于 CentOS 7.1 相同的路径但是wandisco-git-release-7-1.noarch.rpm.

你可以检查可用的版本http://opensource.wandisco.com/centos/7/git/x86_64/


leo*_*luk 8

Red Hat 维护着 Git 2.9 的软件集合:

https://www.softwarecollections.org/en/scls/rhscl/rh-git29/

这是在 CentOS 上获取 Git 2.x 最简单、最安全的方法。

  • 这很好,但目前仅适用于 x86_64 basicarch (2认同)

Dom*_*omQ 5

如今,端点git2u上有一个合适的 git 包(不是):

yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
yum -y install git
Run Code Online (Sandbox Code Playgroud)