How to Install Git on CentOS 8
3 min read
Git is a distributed version control system that’s being used by most software teams today. It allows you to keep track of your code changes, revert to previous stages, create branches , and to collaborate with your fellow developers.
Git is originally developed by Linus Torvalds , the creator of the Linux kernel.
This tutorial explains how to install Git on CentOS 8.
The easiest and the recommended way to install Git is to install it using the
yum package management tool.
If you want to install the latest stable version of Git from source, scroll down to the Installing Git from the Source section of this tutorial.
Installing Git with Yum
The Git package is included in the CentOS’s default repositories.
Run the following command as root or user with sudo privileges to install Git on your CentOS system:
sudo yum install git
Verify the installation by typing the command below, which will print the Git version:
At the time of writing this article, the current version of Git available in the CentOS 8 repositories is
git version 2.18.1
That’s it! You have installed Git, and you’re ready to use it.
Installing Git from the Source
Compiling Git from the source allows you to install the latest Git version and to customize the build options. However, you will not be able to maintain your Git installation through the
yum package manager.
Start by installing the dependencies necessary to build Git on CentOS:
sudo yum groupinstall "Development Tools"
sudo yum install curl-devel expat-devel gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
Once the installation is complete, open your browser, visit the Git project’s mirror on GitHub and copy the latest release link URL that ends in
Currently, the most recent stable Git version is
2.23.0, but it may be different for you.
We are going to download Git source in the
/usr/src directory, which is the common location to place source files. Navigate to the directory :
Download the tar.gz file as
git.tar.gz using the link you copied earlier:
sudo wget https://github.com/git/git/archive/v2.23.0.tar.gz -O git.tar.gz
Next, extract the tarball and change to the git source directory by typing:
sudo tar -xf git.tar.gz
Run the following two commands to compile and install Git on your CentOS system:
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install
git --version to verify the installation:
git version 2.23.0
Later, when you want to update to a newer version, download the archive and repeat the build process.
Now that you have Git installed on your CentOS machine, it is a good idea to set up your personal information. The following commands will set your commit name and email address:
git config --global user.name "Your Name"
git config --global user.email "email@example.com"
To confirm that you have set your information correctly in Git, type:
git config --list
user.name=Your Name firstname.lastname@example.org
The configuration settings are stored in the
[user] name = Your Name email = email@example.com
If you want to make additional changes to the global Git configuration, use either the
git config command or edit the
~/.gitconfig file by hand.
Installing Git on CentOS 8 is a matter of running a single
yum command. If you want to use the latest Git version, you’ll need to build it from the source.
If you are new to Git check the Pro Git book , which is an excellent resource for learning about how to use Git.
Leave a comment below if you hit a problem or have feedback.