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.

yum install \ \

yum remove git
yum install git224

The version of git installed is 2.24.4.

The following also work:

yum -y install
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 -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 $HOME/local/bin to your PATH:

export PATH="$HOME/local/bin:$PATH"

Run git --version to check the git version.