
Git is world’s most popular distributed version control system. It used to track changes, revert to previous stages, create branches for many open source and commercial projects. This guide will explains how to install Git on CentOS 8 Linux.
You can install Git using two methods either using yum
package manager or you can Install Git from the Source for latest stable version.
Prerequisites
Before start installation, you should logged in with non-root user account with sudo privileges.
Install Git using Yum
The Git package is available in the CentOS’s default repositories. Run the below command to install Git using yum
:
sudo yum install git
After that, you can verify the installation by checking version:
git --version
git version 2.18.1
You installed Git successfully and ready to use it.
Install Git from the Source
If you want to install latest stable version of Git then it good choice to install from the Source. After that, you will not able be to maintain your Git installation through the yum
package manager.
At first, you should install the dependencies using below commands:
sudo yum groupinstall "Development Tools"
sudo yum install curl-devel expat-devel gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
On completion of installation, visit Git’s mirror on GitHub and find the latest release link URL ending with .tar.gz
extension:

As per above image currently, the most recent stable Git version is 2.24.1
. There might be change when you visit this link.
Common location to store the Git source is /usr/src
directory. So go to that directory using below command:
cd /usr/src/
Type below command with last copied URL link to download latest tar.gz
file of git.
sudo wget https://github.com/git/git/archive/v2.24.1.tar.gz
After that, extract the file put to the git source directory by typing:
sudo tar -xf git.tar.gz
cd git-*
Next, compile and install Git on your CentOS system using below commands:
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install
That’s it. Git is installed successfully. You can verify it by typing:
git --version
git version 2.24.1
To update the version you should repeat the process of download and extract latest files.
Configure Git
Now your Git is installed on your CentOS machine and you need to configure it by setting up email address and username:
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
Don’t forget to replace with your real name and email address.
You can check entered details by typing:
git config --list
user.name=Your Name user.email=youremail@example.com
These settings are stored at ~/.gitconfig
file and you can see content as below:
You can make other git configuration changes by using git config command or you can use text editor to make changes to ~/.gitconfig
file manually.
Conclusion
In this article, we show you multiple ways to install Git on your CentOS 8 system. If you would like to install latest stable version then you should install from Git source. You can get more details about use of Git from Pro Git book.
Feel free to comment below if any question or feedback.
Leave a Reply