You can install the latest version of git on CentOS 7/8 using the yum install git command on all the Linux but if you need a specific version, you will have to add repository or download the tar file from the git.
How To Install Git Latest Version 2.x On CentOS 7 / 8
Check the version by installing the EPEL repository using yum install epel-release -y and you will see the git 1.7 version available in this repository.
Git Version 2.x using repository:
You can install the WANdisco’s repository to get the latest version on your Linux machine. Use the below repository link to install according to your Linux OS version.
For CentOS 6:
For CentOS 7:
When you write “y” and hit the enter it will start the installation of Git on your machine. Once it’s done.
You can check the version using git –version command.
git version 2.22.0
we can also find the Git binary files location using whereis git command. when you configure Jenkins so you can use this path /usr/bin/git to integrate git with Jenkins.
git: /usr/bin/git /usr/share/man/man1/git.1.gz
Install Git 2.22 Using Source code:
Install the required dependencies before compiling the source code using the below commands on your server.
yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel -y yum install gcc perl-ExtUtils-MakeMaker -y
Before installing the new version, you have to remove the older one form your machine using yum remove git -y command.
Now we will download the source file using the below URL.
cd /usr/src wget https://www.kernel.org/pub/software/scm/git/git-2.5.3.tar.gz tar -xvf git-2.5.3.tar.gz
Once you have extracted the tar file and go to inside the folder and run the following commands.
cd git-2.5.3 make prefix=/usr/local/git all make prefix=/usr/local/git install echo 'export PATH=/usr/local/git/bin:$PATH' >> /etc/bashrc source /etc/bashrc
Now you have to check the version using the below command.
git --version git version 2.5.3