• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How To Install Git on CentOS 8

Written by Admin, Updated On December 22, 2019
centos, git
How To Install Git on CentOS 8 Linux

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:

installing-git-from-source

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.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article Linux Shutdown Command
Next Article   Linux Reboot (Restart) Command

Related Posts

  • How to Install Git on Ubuntu 22.04

    How to Install Git on Ubuntu 22.04

    December 10, 2022
  • How to Install Gitea on Ubuntu 22.04

    How to Install Gitea on Ubuntu 22.04

    November 22, 2022
  • How to Install Git on Debian 11

    How to Install Git on Debian 11 Linux

    November 20, 2022

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install SSH Keys on Ubuntu 22.04
    How to Set up SSH Keys on Ubuntu 22.04 January 7, 2023
  • How to Install Mongodb on Debian 11
    How to Install MongoDB on Debian 11 Linux January 11, 2023
  • How to Install Puppet Agent on Ubuntu 22.04
    How to Install Puppet Agent on Ubuntu 22.04 January 22, 2023
  • How to Install Python 3.11 on Debian 11
    How to Install Python on Debian 11 January 25, 2023
  • How to Change-Hostname Ubuntu 22.04
    How to Change Hostname on Ubuntu 22.04 January 19, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook