How To Install Latest Git on AlmaLinux 8

This tutorial intends to teach you How To Install Latest Git on AlmaLinux 8.

Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to track changes in the source code, enabling multiple developers to work together on non-linear development. Linus Torvalds created Git in 2005 for the development of the Linux kernel.

Steps To Install Latest Git on AlmaLinux 8

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide the Initial Server Setup with AlmaLinux 8.

Install Git From source on AlmaLinux 8

Git packages are available in the default AlmaLinux repository. But in this guide, we will install Git in the latest version.

First, update your local package index with the command below:

sudo dnf update -y

Then, use the following command to install the required packages and dependencies:

sudo dnf install gettext-devel curl-devel expat-devel openssl-devel perl-CPAN perl-devel zlib-devel unzip cmake gcc make wget -y

Now you need to visit the Git Release page and find the master zip archive or the latest stable release from Git.

Next, use the wget command to download the Latest git on AlmaLinux 8:

wget https://github.com/git/git/archive/refs/tags/v2.37.3.zip

When your download is completed, unzip your file with the command below:

sudo unzip v2.37.3.zip

Switch to your Git directory:

cd git-2.37.3

At this point, use the following commands to install the Git:

# sudo make prefix=/usr/local all
# sudo make prefix=/usr/local install

When you are done, verify your Git installation on AlmaLinux 8 by checking its version:

git --version
Output
git version 2.37.3

Setup and Configure Git on AlmaLinux 8

At this point, you must configure Git so that the generated commit messages you make will contain the correct information and support you as you build your software project.

You must provide your name and email address because Git embeds this information into each commit you do. To do this, you can use the following commands:

# git config --global user.name "Your Name"
# git config --global user.email "[email protected]"

After setting up the user name and email ID, you can verify the details using git config --list command:

git config --list
Output
user.name=Your Name
user.email=[email protected]

All the configuration done through the git command will save the information in a file called .gitconfig in the user’s home directory. So you can also verify the configuration by checking this file using cat ~/.gitconfig command as shown below:

cat ~/.gitconfig
Output
[user]
   name=Your Name
   email=[email protected]

Testing Git

Now that you have set up Git on AlmaLinux 8, you can try using it by performing git clone operations from GitHub.

We can just clone a repository called wig by using git clone https://github.com/jekyc/wig.git command as shown below. This will create a directory wig in your local system and copy all the contents from the repository:

git clone https://github.com/jekyc/wig.git
Output
Cloning into 'wig'...
remote: Enumerating objects: 4240, done.
remote: Total 4240 (delta 0), reused 0 (delta 0), pack-reused 4240
Receiving objects: 100% (4240/4240), 4.47 MiB | 12.31 MiB/s, done.
Resolving deltas: 100% (2832/2832), done.

Also, you can check all the subcommands available with the git command using git help -a command as shown below:

git help -a

To have the git status, you can use the command below:

git status

Conclusion

At this point, you have learned to Install the Latest Git on AlmaLinux 8.

Hope you enjoy it.

You may be like these articles:

Install and Configure NTP Server and Client on AlmaLinux 9

How To Install MariaDB 10.9 on AlmaLinux 9

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!