I used the usual:
yum install git
It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7.
I used the usual:
yum install git
It did not install the latest version of git on my CentOS 6. How can I update to the latest version of git for CentOS 6? The solution can be applicable to newer versions of CentOS such as CentOS 7.
as git says:
there is good tutorial here. in my case (Centos7 server) after install had to logout and login again.
My personal preference is to build rpm packages for CentOS when installing non-standard software and replacing distributed components. For this I recommend that you use Mock to create a clean build environment.
The procedure is:
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:
Add a rpm build user account (do not build as root or as a real user - security issues will come back to bite you).
Next we need a build environment.
This produces the following directory structure:
We are using a prepared SRPMS so the SOURCES tarballs can be ignored for this case and we can go direct to SRPMS.
Configure mock (as root)
Disable the
beta
repos. Enable thebase
andupdate
repos.Initialize the build tree (/var/lib/mock is default)
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: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:
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 uponperl-Git2u-2.5.3-1.ius.el6.noarch.rpm
andperl-Git2u-2.5.3-1.ius.el6.noarch.rpm
depends upongit2u-2.5.3-1.ius.el6.x86_64.rpm
. A straight install withrpm
will thus fail.There are two ways of dealing with it:
Install both at the same time via yum:
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.You also may be required to manually pre-install additional dependency packages such as
perl-TermReadKey
available from the usual repositories.Build latest version of
git
on Centos 6/7Preparing system to building rpms
Install epel:
For EL6, use:
For EL7, use:
Install
fedpkg
:Add yourself into group mock (you might need to re-login to server after this change):
Download
git
Download
git
sources:Verify sources:
Build rpm
Create srmp. Use
el6
for RHEL6,el7
for RHEL7.Build package in mock:
Install latest version of
git
rpm from/var/lib/mock/epel-7-x86_64/result/
. Note, you might need to uninstall existing version of the git from your system first.This instruction is based on the mailing list post by Todd Zullinger.
You can use WANDisco's CentOS repository to install Git 2.x: for CentOS 6, for CentOS 7
Install WANDisco repo package:
Install the latest version of Git 2.x:
Verify the version of Git that was installed:
As of 18th Aug. 2017, the latest available version from WANDisco is 2.14.1.
Having a look at the blog here I found the solution in one of the comments. Make sure you got the
rpmforge
repository added to your CentOS yum and just run the flowing command:If you already have git installed then use:
Related question(s):
Note update:
Thanks to Anthony Hatzopoulos, for
git v1.8x
you'll need to use git18 as in:Note update 2:
Also thanks to @Axlrod for the below hint and @Hiphip for the feedback:
Change the
rpmforge.repo
file to haverpmforge-extras
to enabled,yum update git
. Otherwise it complained about dependency problems.Note update 3:
http://tecadmin.net/install-git-2-0-on-centos-rhel-fedora/
(And pasted/reformatted from above source in case it is removed later)
Step 1: Install Required Packages
Firstly we need to make sure that we have installed required packages on your system. Use following command to install required packages before compiling Git source.
Step 2: Uninstall old Git RPM
Now remove any prior installation of Git through RPM file or Yum package manager. If your older version is also compiled through source, then skip this step.
Step 3: Download and Compile Git Source
Download git source code from kernel git or simply use following command to download Git 2.0.4.
After downloading and extracting Git source code, Use following command to compile source code.
Step 4. Check Git Version
One completion of above steps, you have successfully install Git in your system. Let use following command to check git version
I also wanted to add that the "Getting Started" guide at the GIT website also includes instructions on how to download and compile it yourself:
http://git-scm.com/book/en/v2/Getting-Started-Installing-Git
Here's my method to install git on centos 6.