Git is a distributed version control system that allows multiple people to work on a project at the same time without overwriting each other’s changes. As of today, it is the de facto standard for version control in the software development industry.
In this guide, we will walk you through the process of installing the latest Git from source on CentOS/RHEL/Fedora. This method is beneficial when you want to use the most recent version of Git that may not yet be available in the default repositories of your operating system.
Before you begin, you will need:
- A system running CentOS, RHEL, or Fedora.
- Root or sudo access to the system.
Step 1: Install the Necessary Dependencies
Before we can build Git from source, we first need to install the software that Git depends on. This includes the ‘Development Tools’ group which provides basic build tools, and some additional libraries Git needs.
Open a terminal window and run the following command:
sudo yum groupinstall 'Development Tools'
sudo yum install gettext-devel openssl-devel perl-CPAN git perl-devel zlib-devel curl-devel
Step 2: Download the Latest Git Source
Next, we need to download the source code for the latest version of Git. We’ll do this by cloning the Git source repository.
First, navigate to the directory where you want to download the source code. In this example, we’ll use /usr/src.
Then, clone the Git repository:
sudo git clone https://github.com/git/git.git
Step 3: Build and Install Git
Now, navigate into the git directory that was created when we cloned the repository:
Before building Git, it’s a good idea to check out the latest release tag. This ensures you’re building a stable version of Git, rather than the bleeding-edge master branch. You can see all tags with the command `git tag`, and switch to a tag with `git checkout <tagname<`.
To compile and install Git, use the make and make install commands:
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install
This will compile Git and install it under /usr/local.
Step 4: Verify the Installation
Once the installation is complete, you can verify that it was successful by checking the Git version:
This should output the version of Git that you just installed.
That’s it! You have successfully installed the latest version of Git from source on your CentOS/RHEL/Fedora system. You can now take advantage of all the latest features and improvements in Git.
Remember, Git is updated frequently, so it’s a good idea to check for new releases regularly. You can do this by navigating to the Git directory (/usr/src/git in this example) and running git pull to fetch the latest changes. Then, simply repeat the build and install steps.