Install a newer version of Git on CentOS 7

Solution 1:

You could use a IUS repository (https://ius.io/) as provided on Git official site here or here. It contains prebuilt binaries for x86_64.

To do that, run (as root):

yum install epel-release
yum remove git
rpm -U https://centos7.iuscommunity.org/ius-release.rpm
yum install git2u

(centos7 can be replaced with centos6 or rhel{6,7} if you are not using CentOS).

Note: some users report that there is no more package called git2u. You can also try packages git222 or git224 in that case.

Another option would be to use another RPM repository (i386 & x86_64):

sudo yum -y install https://packages.endpointdev.com/rhel/7/os/x86_64/endpoint-repo.x86_64.rpm
sudo yum install git

Solution 2:

Building from source is quite straightforward. Digital Ocean has a nice guide on building Git from source on CentOS 7. Place the resulting binary in /usr/local/bin/ on your CentOS 7 system (which, by default, is included in your $PATH) and you're good to go.

Of course you would prefer packages/using the repo, however given your situation I would not hesitate building it myself.

For general information; Push to Deploy was introduced in Git 2.3.0. Make sure to use this version or above.

Solution 3:

I have this approach for 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

At the moment I have 2.10.0 GIT version.

Or for CentOS 7.1 the same path but wandisco-git-release-7-1.noarch.rpm.

You may inspect available releases http://opensource.wandisco.com/centos/7/git/x86_64/

Solution 4:

Red Hat maintains a software collection for Git 2.9:

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

This is the easiest and safest way to get Git 2.x on CentOS.

Solution 5:

What is working for me for CentOS 7.4:

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 git224

Ref:

  • https://ius.io/setup