
In this tutorial, we will install Git on AlmaLinux 10. Git is a free and open-source distributed version control system. It was created by Linus Torvalds(The inventor of the Linux Operating System) for version control in the development of the Linux kernel. Git is designed to track changes in code and other files throughout the software development process. Git offers a variety of features, including a distributed architecture, version control, snapshots, branching, merging, and collaboration. We can describe Git as a “time machine” for our code, because it allows us to revert changes and manage different versions of a project from its creation to the latest version.
Git can be installed on AlmaLinux 10 in two ways: either from the default repository or by building it from source. The faster way is to install from the default repository, which takes less than a minute. However, if you want to build an older or specific version, then building from source is the recommended approach. Let’s learn both ways!
Table of Contents
Prerequisites
- A server running AlmaLinux 10 OS
- User privileges: root or non-root user with sudo privileges
Update your system
Before installing Git or any other Git prerequisites, it is a good practice to update the system packages to their latest versions available. To do that, execute the following command in your terminal of AlmaLinux 10:
sudo dnf update -y && sudo dnf upgrade -y
Install Git from AlmaLinux Repository
As we mentioned previously, installing Git from the default AlmaLinux 10 repository is the fastest and easiest way. Since Git is included in the repository of AlmaLinux 10, it can be installed with the following command:
sudo dnf install git -y
Once it is installed, you can check the installed version with the following command:
git -v
You should receive output similar to this:
[root@test.vps ~]# git -v git version 2.47.3
At the time we were writing this tutorial, the default Git version on AlmaLinux 10 was 2.47.3. Let’s proceed to the next paragraph and learn how to install the latest stable release of Git.
Install Git from Source
Installing Git from source on AlmaLinux 10 provides access to the latest features and versions that are not yet available in the distribution’s package manager. At the moment we were writing the post, the latest stable release of Git was 2.51.2.
To install this version from source, first, we need to install some dependencies. To do that, execute the following commands one by one:
sudo dnf update -y && sudo dnf upgrade -y sudo dnf groupinstall -y "Development Tools" sudo dnf install -y gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel curl-devel expat-devel
Once the prerequisites are installed, we need to download GitHub:
cd /opt wget https://github.com/git/git/archive/refs/tags/v2.51.2.tar.gz tar -xzf v2.51.2.tar.gz mv git-2.51.2/ git/ cd git/
After downloading the latest stable version and extracting the folder, we can proceed with the compilation process. Execute the following commands one by one after every successfully completed command:
make configure ./configure --prefix=/usr/local make all sudo make install
Once Git is installed, we need to add the new installation of GIT to the system’s PATH environment variable:
echo 'export PATH=/usr/local/bin:$PATH' >> ~/.bashrc source ~/.bashrc
To verify the installation, execute the following command:
git --version
You should receive output with the latest stable version 2.51.2:
[root@test git]# git --version git version 2.51.2
The Git commands
This is a list of the most used and most important Git commands:
Basic Setup & Init git config --global user.name "Your Name" - set your name globally git config --global user.email "you@example.com" - set your email globally git init - initialize a new Git repository in the current directory git clone - make a local copy of a remote repository. Daily Workflow git status - show which files are changed, staged, unstaged git add - stage one or more files for commit git add . - stage all changed files in the current directory and subdirectories git commit -m "Your message" - commit the staged changes with a message git push origin - send local branch commits to the remote repository git pull origin — fetch from remote and merge into local, bringing your branch up-to-date Branching & Switching git branch - list existing branches git branch - create a new branch git branch feature/login git checkout - switch to another branch git checkout feature/login git checkout -b - a shortcut to create and switch to a new branch git checkout -b feature/signup git merge - merge the named branch into the current branch Inspecting History & Changes git log - show the commit history git log --oneline - show a compact, one-line per commit version of the history git diff - show changes that are not yet staged or committed Remote & Repo Management git remote -v - show remote repositories (URLs) associated with your repo git remote -v git remote add origin - add a remote repository called “origin” git remote add origin https://github.com/user/repo.git git push --delete origin - delete a branch on the remote Undoing / Fixing Mistakes git reset --hard HEAD~1 - reset your branch to one commit back, discarding changes (use with caution) git stash - stash local changes temporarily, to clean working directory but come back to them later git stash git revert - create a new commit that undoes the specified commit. (Safe in shared branches.)
That’s it. You successfully installed Git on AlmaLinux 10 OS.
Of course, you don’t have to install Git on AlmaLinux 10 if you have difficulties and you are not familiar with Linux. You can always contact our technical support. You only need to sign up for one of our monthly management plans and submit a support ticket. We are available 24/7 and will attend to your request promptly.
If you liked this post about installing Git on AlmaLinux 10, please share it with your friends or leave a comment down below.