The version of the default git bundled with the Linux system is often too old, and lacks certain features, which may break some tools. This post summarizes how to install newer versions of Git on Linux.
Install via package manager
If you have root rights, you can install new version of git via yum.
# https://ius.io/setup 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
The version of git installed is 2.24.4.
The following also work:
yum -y install https://packages.endpoint.com/rhel/7/os/x86_64/endpoint-repo-1.7-1.x86_64.rpm yum remove git yum install git
Compile and install git from source
First, we need to install some dependency packages. Note that if we use https protocol for git, we need to install curl development package:
yum install libcurl-devel
Otherwise, when you git clone using a https url:
git clone https://xxx.xx.xx,
you get an error:
git: ‘remote-https’ is not a git command. See ‘git –help’.
If you do not have root rights, you can also build curl from source.
Then, run the following script to build git from source:
wget https://github.com/git/git/archive/refs/tags/v2.31.1.tar.gz -O git.tar.gz tar xvf git.tar.gz cd git-* mkdir -p $HOME/local make configure ./configure --prefix=$HOME/local make -j && make install
git will be installed under
$HOME/local/bin. Then, add
git --version to check the git version.
License CC BY-NC-ND 4.0