How to Install git on CentOS 7/8 ?

Git is the most widely used open source version control system that tracks all files in a project and every file change is detected and versioned. You would therefore a modification history which allows you to consult it and even go back in case of error.

We will see in this article the two methods to install git on CentOS.

Installation with yum or dnf :

Use the command below to install our package with yum or dnf :

[root@server ~]# dnf install git
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/2): extras/7/x86_64/primary_db | 243 kB 00:00:01
(2/2): updates/7/x86_64/primary_db | 10 MB 00:00:27
Resolving Dependencies
--> Running transaction check
---> Package git.x86_64 0: will be installed
--> Processing Dependency: perl-Git = for package: git-
--> Processing Dependency: perl >= 5.008 for package: git-
--> Processing Dependency: rsync for package: git-
--> Processing Dependency: perl(warnings) for package: git-
--> Processing Dependency: perl(vars) for package: git-
--> Processing Dependency: perl(strict) for package: git-
--> Processing Dependency: perl(lib) for package: git-
--> Processing Dependency: perl(Term::ReadKey) for package: git-

Once installed, you can check the version with the command below :

[root@server ~]# git --version
git version

Install git from source :

If you want to download the latest version then you need to compile git from source, It takes longer and will not be updated and maintained through the yum package manager, but it will allow you to download a newer version than the one available through CentOS repositories.

First we will need to install some dependencies available from the CentOS repository :

[root@server ~]# yum groupinstall "Development Tools"
[root@server ~]# yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel

After installing the necessary dependencies, you can find the version of Git you want to install by visiting this page.


Copy the link of the package you want to install :


We will use the wget command to download this package with the link copied :

[root@server ~]# wget
--2021-09-06 12:03:59--
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 302 Found
Location: [following]
--2021-09-06 12:04:00--
Resolving (…
Connecting to (||:443… connected.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [application/x-gzip]
Saving to: ‘v2.33.0.tar.gz’
[ <=> ] 10,336,788 1.07MB/s in 12s
2021-09-06 12:04:12 (845 KB/s) - ‘v2.33.0.tar.gz’ saved [10336788]

if you don’t wget installed, you can install it with the command below :

[root@server ~]# yum install wget

We must now extract the tar.gz file :

[root@server ~]# tar xzf v2.33.0.tar.gz
[root@server ~]# ll
total 566140
drwxrwxr-x. 26 root root 16384 Aug 16 15:15 git-2.33.0

Go to the extracted folder and type the commands below :

[root@server ~]# make configure
[root@server ~]#./configure --prefix=/usr/local
[root@server ~]# make install

Git is now installed, type the command below to check the version :

[root@server git-2.33.0]# git --version
git version

Now that our git is installed, we need to provide some information about us (name, email) so the validation messages are generated with the information provided :

[root@server]# git config --global user.nom "Votre Nom"
[root@server]# git config --global ""

To make sure that the information is correctly provided, type the command below :

[root@server]# git config --list
user.nom=Votre Nom

Now git is properly installed and ready to use on your system.

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *