Hello, friends. Git is one of the most popular tools among developers. It is almost a must to use it in the development of any application and although it has a lot of support on Linux, it is also true that many prefer other means of installation. So, in this post, you will learn how to install Git from the source code on CentOS 8.
Git is a free and open-source distributed version control system. It is perhaps the most popular within the branch as millions of developers use it to control software versions. Ease of use, community support, and efficient version control are the main features of Git. Also, it is open-source and free, which makes it ideal for all projects.
The answer to this question can be summed up as efficiency. When we install a program from the source code, only what is necessary to work according to our system and hardware is installed. This makes it faster and more efficient.
On the other hand, there is a security issue. When a package comes already done and we install it, at the end we won’t know who compiled it and under what parameters it was done. This is not the end of the world because we know that in Linux, the repositories are quite taken care of by the developers of the distributions, but, indeed, it is not compiled specifically for us.
Therefore, if you are thinking of using it in a company or a personal project, compiling it can assure you even more efficiency and security.
Finally, learning to compile packages is a great help for working with Linux and can also be used in other areas.
The procedure is quite simple. First, open a terminal and update CentOS 8.
Note in this post, we will use the root user. If your user can use sudo, you can run the commands with root privileges.
After that, install the required libraries and dependencies.
dnf install gettext-devel openssl-devel perl-CPAN perl-devel perl-devel zlib-devel gcc autoconf curl-devel expat-devel gettext-devel wget tar
Next, download the source code from Git. At the time of writing this post, the latest stable version is
wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.30.1.tar.gz -O git.tar.gz --2021-02-22 20:58:12-- https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.30.1.tar.gz Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 2604:1380:2001:3900::1, 126.96.36.199 Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|2604:1380:2001:3900::1|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 9864833 (9.4M) [application/x-gzip] Saving to: ‘git.tar.gz’ git.tar.gz 100%[=====================================================================================>] 9.41M --.-KB/s in 0.1s 2021-02-22 20:58:12 (73.6 MB/s) - ‘git.tar.gz’ saved [9864833/9864833]
Next, decompress the archive:
tar -vzxf git.tar.gz
Go to the folder that is generated:
And from there configure the compilation.
make prefix=/usr/local all
And at the end, perform the installation
make prefix=/usr/local install
When the process is finished, Git will be installed. To test it, run the command
git version 2.30.1
This will install Git from the source code. To upgrade, you have to repeat these steps with the new version.
Perhaps compiling the source code of an application yourself is not the most direct way to install it, but it is the most efficient and secure. So it’s always good to do so when there are not too many complications.