Introduction
Git is a popular version control system used by developers to manage their source code. It is a distributed version control system, which means that it allows multiple developers to work on the same project simultaneously. Installing Git on CentOS 8 is a straightforward process that can be completed in a few simple steps. In this guide, we will show you how to install Git on CentOS 8.
How to Install Git on CentOS 8
1. Update the system:
sudo yum update
2. Install the required packages:
sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel
3. Download the latest version of Git:
curl -OL https://github.com/git/git/archive/v2.26.2.tar.gz
4. Extract the downloaded file:
tar -xzf v2.26.2.tar.gz
5. Change the directory to the extracted folder:
cd git-2.26.2
6. Compile and install Git:
make prefix=/usr/local all
sudo make prefix=/usr/local install
7. Verify the installation:
git –version
Introduction
Git is a popular version control system that organizes the development cycle of an application. Git is used by developers to keep track of code changes, create branches, and collaborate within a software team.
This article will show you two options of how to install Git on CentOS 8.
Prerequisites
- A Linux-based system with CentOS 8 installed
- Access to the root user or an account with sudo privileges
- DNF package manager (comes by default with CentOS 8)
Install Git on CentOS 8 from Local Repository
The easiest way to install Git is to download the package from your local repository. This installs the latest version of the software available on the CentOS repository.
1. Open a terminal window and update the repository with the command:
dnf update
2. Now, install Git with the command:
dnf install git
3. Verify the installation of Git on CentOS 8 by prompting for the version information:
git --version
The system should answer the query with the release number of the package as seen below.
Install Git on CentOS 8 from Source Code
Another way to install Git on CentOS 8 is directly from the source code. Doing so allows you to choose the Git version and/or download the latest release. You can also customize the build options to suit the needs of you and your team.
1. Before you download the Git package, install the required dependencies with the command:
dnf groupinstall "Development Tools"
2. You also need to install libraries used for Git compilation:
dnf install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-CPAN perl-devel
3. Once you have all the necessary dependencies, navigate to the /usr/src directory where you want to download the source package:
cd /usr/src/
Depending on the version of Git you want to download, the URL in the following step will differ. Visit the official Git repository to see all of the available releases. Currently, v.2.24.0 is the latest master version and the one we are installing in this article.
4. For the latest stable version, copy the URL of the tar.gz file of v2.24.0 and paste it in the command:
wget https://github.com/git/git/archive/v2.24.0.tar.gz -O git.tar.gz
5. Extract the tar package with:
tar -xf tir.tar.gz
6. Now compile Git and install it on your CentOS 8. Move to the git directory, compile, and install it with the following commands:
cd git-*
make prefix=/usr/local all
make prefix=/usr/local install
With this, you have finished the installation process.
7. As a final step, verify the installed Git version:
git --version
Set Up and Configure Git
Once you have installed Git, configure the software with your personal information. This info is displayed when generating commit messages.
To set up the name use the command:
git config --global user.name "Your Name"
Set up the email address with:
git config --global user.email "[email protected]"
Verify the configured information:
git config --list
Conclusion
After reading this article, you should have installed and set up Git on CentOS 8, either from the local repository or the source code.
Download our Git Commands Cheat Sheet for free to have the most commonly used commands always at your hand.
How to Install Git on CentOS 8
Git is a popular version control system used by developers to manage their source code. It is widely used in the open source community and is the preferred version control system for many projects. In this tutorial, we will show you how to install Git on CentOS 8.
Prerequisites
Before you begin, you will need to have a CentOS 8 server with a non-root user with sudo privileges. You can learn how to set up a user with these privileges by following our initial server setup guide for CentOS 8.
Step 1 — Installing Git
The first step is to install Git on your CentOS 8 server. We can do this by using the dnf
package manager. To install Git, run the following command:
sudo dnf install git
Once the installation is complete, you can verify the version of Git installed by running the following command:
git --version
You should see output similar to the following:
git version 2.18.1
Step 2 — Configuring Git
Now that Git is installed, you can configure it with your name and email address. This information will be used to identify you when you commit changes to your repositories. To set your name, run the following command, replacing Your Name
with your actual name:
git config --global user.name "Your Name"
To set your email address, run the following command, replacing [email protected]
with your actual email address:
git config --global user.email "[email protected]"
You can verify that the settings were applied correctly by running the following command:
git config --list
You should see output similar to the following:
user.name=Your Name
[email protected]
Conclusion
In this tutorial, you learned how to install and configure Git on your CentOS 8 server. You can now start using Git to manage your source code.