Git is a version-control system, which is used for tracking updates in computer files. Additionally, it may be used for collaborating work on files among a group of people. This article will provide the reader with a step by step information on how to install Git on RHEL 8 / CentOS 8.
In this tutorial you will learn:
- How to install Git from a standard RHEL 8 / CentOS 8 repository.
- How to compile and install Git from source code.
- How to check Git version.
Software Requirements and Conventions Used
Category | Requirements, Conventions or Software Version Used |
---|---|
System | RHEL 8 / CentOS 8 |
Software | N/A |
Other | Privileged access to your Linux system as root or via the sudo command. |
Conventions |
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command$ – requires given linux commands to be executed as a regular non-privileged user |
Install Git from a standard RHEL 8 / CentOS 8 repository step by step instructions
Chances are that the git
command is already available on your RHEL 8 system. Execute git --version
to check whether the git
tool is already installed.
- Use the
dnf
command to install the packagegit
:# dnf install git
- Confirm installation by checking the
git
command version number:$ git --version git version 2.18.1
Compile and Install Git from a source code step by step instructions
In case you need to install a specific Git version on your RHEL 8 system then use the below steps to compile and install Git from a source code.
- Use the
dnf
command to install all prerequisites:# dnf install wget unzip tar make gcc openssl-devel libcurl-devel expat-devel
- Download the Git source code package URL from official git repository. Either download the latest master version or use tags to download any other available git version.
- Use the
wget
command to download the git source zip package. For example in this case we are downloading the git versionv2.20.1
:$ wget https://github.com/git/git/archive/v2.20.1.zip
- Unzip the git source code:
$ unzip v2.20.1.zip
- Navigate to the git source code directory:
$ cd git-2.20.1/
- Compile and install git:
# make prefix=/usr/local all install
- Confirm git installation:
$ git --version git version 2.20.1