我用了通常的:
yum install git
它没有在我的CentOS 6上安装最新版本的git。如何更新到CentOS 6的最新版本?该解决方案适用于CentOS 7等更新版本的CentOS。
我用了通常的:
yum install git
它没有在我的CentOS 6上安装最新版本的git。如何更新到CentOS 6的最新版本?该解决方案适用于CentOS 7等更新版本的CentOS。
当前回答
下面是我在centos 6上安装git的方法。
sudo yum groupinstall "Development Tools"
sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel curl-devel
sudo yum install wget
cd ~
wget -O git.zip https://github.com/git/git/archive/v2.7.2.zip
unzip git.zip
cd git-2.7.2
make configure
./configure --prefix=/usr/local
make all doc
sudo make install install-doc install-html
其他回答
下面是我在centos 6上安装git的方法。
sudo yum groupinstall "Development Tools"
sudo yum install zlib-devel perl-ExtUtils-MakeMaker asciidoc xmlto openssl-devel curl-devel
sudo yum install wget
cd ~
wget -O git.zip https://github.com/git/git/archive/v2.7.2.zip
unzip git.zip
cd git-2.7.2
make configure
./configure --prefix=/usr/local
make all doc
sudo make install install-doc install-html
这可能无关紧要。它是为了人们不希望在主机上构建最新的git,同时他们仍然可以获得最新的git。
我认为大多数人不喜欢在CentOS上构建最新的git,因为依赖关系会污染主机,你必须运行大量的命令。因此,我有一个想法,这是在Docker容器内构建git,然后通过Docker卷安装可执行文件。之后,您可以删除映像和容器。
是的,缺点是你必须安装docker。但最少的依赖被引入到主机,你不需要安装其他yum repo。
这是我的存储库。https://github.com/wood1986/docker-library/tree/master/git
正如git所说:
RHEL及其衍生产品通常会发布较旧版本的git。你可以 下载一个压缩包并从源代码构建,或者使用第三方 如IUS社区项目的存储库,以获得最新的 git的版本。
这里有很好的教程。 在我的情况下(Centos7服务器)安装后不得不注销并再次登录。
在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的邮件列表。
我个人倾向于在安装非标准软件和替换分布式组件时为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。