我用了通常的:

yum install git

它没有在我的CentOS 6上安装最新版本的git。如何更新到CentOS 6的最新版本?该解决方案适用于CentOS 7等更新版本的CentOS。


当前回答

在没有经过大量测试和思考的情况下,将上游基础存储库替换为附加存储库,这是非常令人困惑和危险的。尤其是RPMforge,实际上已经奄奄一息,并且没有得到更新。

我个人在https://github.com/nkadel/git24-srpm/上发布了构建git 2.4的工具,包装成另一个名为“git24”的包。如果您希望将这些包与标准系统包区分开来,就像区分“samba”和“samba4”包一样,您可以随意访问这些包并将其派生出来。

其他回答

我个人倾向于在安装非标准软件和替换分布式组件时为CentOS构建rpm包。为此,我建议您使用Mock来创建一个干净的构建环境。

程序如下:

Obtain the source RPMS or a suitable SPEC file and pristine source tarball. In this case one may find source RPM packages for git2X for CentOS-6 at: http://dl.iuscommunity.org/pub/ius/archive/CentOS/6/SRPMS/. Packages for other CentOS releases are also available. Install the necessary support software: yum install epel-release # you need this for mock yum install rpm-build yum install redhat-rpm-config yum install rpmdevtools yum install mock Add a rpm build user account (do not build as root or as a real user - security issues will come back to bite you). sudo adduser builder --home-dir /home/builder \ --create-home --user-group --groups mock \ --shell /bin/bash --comment "rpm package builder" Next we need a build environment. su -l builder rpmdev-setuptree This produces the following directory structure: ~ └── rpmbuild ├── BUILD ├── RPMS ├── SOURCES ├── SPECS └── SRPMS We are using a prepared SRPMS so the SOURCES tarballs can be ignored for this case and we can go direct to SRPMS. wget http://dl.iuscommunity.org/pub/ius/archive/CentOS/6/SRPMS/git2u-2.5.3-1.ius.centos6.src.rpm \ -O ~/rpmbuild/SRPMS/git2u-2.5.3-1.ius.centos6.src.rpm Configure mock (as root) cd /etc/mock rm default.cfg ln -s epel-6-x86_64.cfg default.cfg vim default.cfg Disable the beta repos. Enable the base and update repos. Initialize the build tree (/var/lib/mock is default) mock --init If we were building from SOURCES then this is where we would employ the SPEC file and use mock --buildsrpm . . .. But in this case we go directly to the binary build step: mock --no-clean --rebuild ~/rpmbuild/SRPMS/git2u-2.5.3-1.ius.centos6.src.rpm This will resolve the build dependencies and download them (about 95 or so packages) into the clean build root. It will then extract the sources and build the binary from the provided SRPM and leave it in /var/lib/mock/epel-6-x86_64/result; or in whatever custom build root location and architecture you provided. It will take a long time. There is a lot to this package; particularly documentation. If all goes well then you should end up with a suit of RPM packages suitable for installation in place of the distro version. This is what I ended up with: ll /var/lib/mock/epel-6-x86_64/result total 34996 -rw-rw-r--. 1 byrnejb mock 448455 Oct 30 10:09 build.log -rw-rw-r--. 1 byrnejb mock 52464 Oct 30 10:09 emacs-git2u-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 47228 Oct 30 10:09 emacs-git2u-el-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 8474478 Oct 30 09:57 git2u-2.5.3-1.ius.el6.src.rpm -rw-rw-r--. 1 byrnejb mock 8877584 Oct 30 10:09 git2u-2.5.3-1.ius.el6.x86_64.rpm -rw-rw-r--. 1 byrnejb mock 27284 Oct 30 10:09 git2u-all-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 27800 Oct 30 10:09 git2u-bzr-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 112564 Oct 30 10:09 git2u-cvs-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 436176 Oct 30 10:09 git2u-daemon-2.5.3-1.ius.el6.x86_64.rpm -rw-rw-r--. 1 byrnejb mock 15858600 Oct 30 10:09 git2u-debuginfo-2.5.3-1.ius.el6.x86_64.rpm -rw-rw-r--. 1 byrnejb mock 60556 Oct 30 10:09 git2u-email-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 274888 Oct 30 10:09 git2u-gui-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 79176 Oct 30 10:09 git2u-p4-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 483132 Oct 30 10:09 git2u-svn-2.5.3-1.ius.el6.x86_64.rpm -rw-rw-r--. 1 byrnejb mock 173732 Oct 30 10:09 gitk2u-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 115692 Oct 30 10:09 gitweb2u-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 57196 Oct 30 10:09 perl-Git2u-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 89900 Oct 30 10:09 perl-Git2u-SVN-2.5.3-1.ius.el6.noarch.rpm -rw-rw-r--. 1 byrnejb mock 101026 Oct 30 10:09 root.log -rw-rw-r--. 1 byrnejb mock 980 Oct 30 10:09 state.log Install using yum or rpm. You will require git2u-2.5.3-1.ius.el6.x86_64.rpm at a minimum and such additional support packages as it requires (perl-Git2u-2.5.3-1.ius.el6.noarch.rpm) or you desire. This build has a cyclic dependency: git2u-2.5.3-1.ius.el6.x86_64.rpm depends upon perl-Git2u-2.5.3-1.ius.el6.noarch.rpm and perl-Git2u-2.5.3-1.ius.el6.noarch.rpm depends upon git2u-2.5.3-1.ius.el6.x86_64.rpm. A straight install with rpm will thus fail. There are two ways of dealing with it: Install both at the same time via yum: yum localinstall \ git2u-2.5.3-1.ius.el6.x86_64.rpm \ perl-Git2u-2.5.3-1.ius.el6.noarch.rpm` Setup a local yum repo. I am including my LocalFile.repo file below as it contains instructions on how to do this and provides the necessary repo file at the same time.

cat /etc/yum.repos.d/LocalFile.repo
# LocalFile.repo
#
#  This repo is used with a local filesystem repo.
#
# To use this repo place the rpm package in /root/RPMS/yum.repo/Packages.
# Then run: createrepo --database --update /root/RPMS/yum.repo.
#
# To use:
#  yum --enablerepo=localfile [command]
#  
# or to use only ONLY this repo, do this:
#
#  yum --disablerepo=\* --enablerepo=localfile [command]

[localfile]
baseurl=file:///root/RPMS/yum.repo
name=CentOS-$releasever - Local Filesystem repo

# Before persistently enabling this repo see the priority note below.
enabled=0
gpgcheck=0

# When this repo is enabled all packages in repos with priority>5
# will not be updated even when they have a more recent version.
# Be careful with this.
priority=5

您还可能需要手动预安装其他依赖包,例如从通常的存储库中获得的perl-TermReadKey。

在没有经过大量测试和思考的情况下,将上游基础存储库替换为附加存储库,这是非常令人困惑和危险的。尤其是RPMforge,实际上已经奄奄一息,并且没有得到更新。

我个人在https://github.com/nkadel/git24-srpm/上发布了构建git 2.4的工具,包装成另一个名为“git24”的包。如果您希望将这些包与标准系统包区分开来,就像区分“samba”和“samba4”包一样,您可以随意访问这些包并将其派生出来。

您可以使用WANDisco的CentOS存储库来安装Git 2。x: CentOS 6, CentOS 7

安装WANDisco回购包: Yum install http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm -或- Yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-1.noarch.rpm -或- Yum install http://opensource.wandisco.com/centos/7/git/x86_64/wandisco-git-release-7-2.noarch.rpm 安装最新版本的Git 2.x: Yum安装git 验证已安装Git的版本: git -版本

截至2020年3月2日,WANDisco的最新可用版本为2.22.0。

要在CentOS 6上构建和安装现代Git:

yum install -y curl-devel expat-devel gettext-devel openssl-devel zlib-devel gcc perl-ExtUtils-MakeMaker
export GIT_VERSION=2.6.4
mkdir /root/git
cd /root/git
wget "https://www.kernel.org/pub/software/scm/git/git-${GIT_VERSION}.tar.gz"
tar xvzf "git-${GIT_VERSION}.tar.gz"
cd git-${GIT_VERSION}
make prefix=/usr/local all
make prefix=/usr/local install
yum remove -y git
git --version # should be GIT_VERSION

这个指南奏效了:

# hostnamectl
  Operating System: CentOS Linux 7 (Core)
# git --version
git version 1.8.3.1
# sudo yum remove git*
# sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
# sudo yum install git
# git --version
git version 2.24.1