How to Install Git on CentOS
Git is a form of version control – a critical software configuration management tool. With the benefit of a version control system, you can track, annotate, and organize changes to documents, websites, computer programs, and many other kinds of collected information.
Let’s walk through the process of installing Git on CentOS.
Option 1: Install Git with Yum
The easiest, fastest way to install Git is with yum, CentOS’s package manager.
1. Find and install the latest version with the command:
yum install git
2. Verify the installation using the command:
git --version
The output should display the version number of Git that you have installed successfully.
Option 2: Install Latest Version of Git from IUS Repository
If you are seeking a custom range of options, you may prefer to install Git from IUS, a community-run source of quality packages stored in the .rpm file format (RPM packages).
1. Install Development Tools
Go to your default repositories provided in CentOS, and retrieve the necessary tools to build a binary for the version of Git you plan to install.
sudo yum groupinstall "Development Tools"
Then run this command:
sudo yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
2.Installation From Source
Install CentOS 7 repo from IUS using the command:
sudo yum install https://centos7.iuscommunity.org/ius-release.rpm
Then:
sudo yum install git2u-all
Now, you should have the latest version.
Perform a version check for Git on your CentOS 7 server with the command:
git --version
This ensures you have successfully installed the desired version of Git onto the CentOS server.
Configure Git
It’s a best practice to configure your name and email address in Git.
1.Set your name
git config --global user.name "Your Name"
2.Set your email address
git config --global user.email "[email protected]"
3.Verify the settings
git config --list
You might see, for example:
user.name=Your name
[email protected]
Remove Git with Yum
sudo yum remove git
After setting up Git on your server, you may want to browse the full Git documentation.