我用了通常的:
yum install git
它没有在我的CentOS 6上安装最新版本的git。如何更新到CentOS 6的最新版本?该解决方案适用于CentOS 7等更新版本的CentOS。
我用了通常的:
yum install git
它没有在我的CentOS 6上安装最新版本的git。如何更新到CentOS 6的最新版本?该解决方案适用于CentOS 7等更新版本的CentOS。
当前回答
如果git已经安装,首先删除旧的git
sudo yum remove git*
并安装最新版本的git
yum install -y git-core
检查版本 git -版本
宾果!
其他回答
我个人倾向于在安装非标准软件和替换分布式组件时为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”包一样,您可以随意访问这些包并将其派生出来。
在Centos 6/7上构建最新版本的git
准备系统建立rpm
安装epel: 对于EL6,使用: Sudo yum安装https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm 对于EL7,使用: Sudo yum安装https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm 安装fedpkg: Sudo yum安装fedpkg 将自己添加到组mock(更改后您可能需要重新登录服务器): sudo usermod -a -G mock $USER
下载
下载git源代码: Fedpkg克隆-一个git && CD git fedpkg来源 验证来源: Sha512sum -c源
构建rpm
创建srmp。用el6代替RHEL6,用el7代替RHEL7。 Fedpkg—dist el7 SRPM 在mock中构建包: 模拟-r eel -7-x86_64 git-2.16.0-1.el7.src.rpm 从/var/lib/mock/ eel -7-x86_64/result/安装最新版本的git rpm。注意,您可能需要首先从系统中卸载现有版本的git。
本指南基于Todd Zullinger的邮件列表。
这可能无关紧要。它是为了人们不希望在主机上构建最新的git,同时他们仍然可以获得最新的git。
我认为大多数人不喜欢在CentOS上构建最新的git,因为依赖关系会污染主机,你必须运行大量的命令。因此,我有一个想法,这是在Docker容器内构建git,然后通过Docker卷安装可执行文件。之后,您可以删除映像和容器。
是的,缺点是你必须安装docker。但最少的依赖被引入到主机,你不需要安装其他yum repo。
这是我的存储库。https://github.com/wood1986/docker-library/tree/master/git
Rackspace维护ius存储库,其中包含一个相当最新的git,但必须首先删除库存git。
CentOS 6或7指令(以root用户或sudo运行):
# retrieve and check CENTOS_MAIN_VERSION (6 or 7):
CENTOS_MAIN_VERSION=$(cat /etc/centos-release | awk -F 'release[ ]*' '{print $2}' | awk -F '.' '{print $1}')
echo $CENTOS_MAIN_VERSION
# output should be "6" or "7"
# Install IUS Repo and Epel-Release:
yum install -y https://repo.ius.io/ius-release-el${CENTOS_MAIN_VERSION}.rpm
yum install -y epel-release
# re-install git:
yum erase -y git*
yum install -y git-core
# check version:
git --version
# output: git version 2.24.3
注意:git-all通常会安装旧版本而不是git-core。试试git224-all。
该脚本在CentOS 7 docker映像(7e6257c9f8d8)和CentOS 6 docker映像(d0957ffdf8a2)上进行测试。