A version control system is a piece of software that records changes to a file or set of files over time so that you can recall specific versions of these files at a later date. The need for version control is not limited to developers in today’s complex and mission-critical infrastructure environments. System administrators too can make efficient use of version control to track changes in their scripts and/or place different configuration files under version control.
GIT is a powerful distributed version control system, perhaps the most powerful and feature-rich version control system available as of this writing.
We’ve already briefly talked about the need for version control for system administrators and in this article, we will talk about how GIT came into existence and how to install it on a centos system.
History of GIT
GIT was created by Linus Torvalds in 2005. It is written in Perl and C. The GIT project was essentially started as a substitute version control system for the Linux Kernel after BitKeeper withdrew its support. This project has since become immensely popular among since the emergence of the devops movement and framework and continues to increase its popularity.
GIT Design goals:
- Strong branch/merge support
- Scales well for large projects
We mentioned in our introduction that GIT is a distributed version control system. Given below are the advantages of distributed version control systems over other types:
- Developers generally push changes to their own repository which are then pulled into the official repository by the project maintainers.
- Cloning of repositories serves as an easy way to backup projects as each clone is a full backup.
- Allows branches and applying fixes to different branches.
- A full local history is available along with other repository statistics.
- Deployment is very streamlined.
GIT runs on Linux, OS X, Windows, and many other operating systems.
Now we will show you how to install GIT via yum. For RedHat and Centos systems, the git package along with its dependencies is available in the base repository. To install git via yum we execute the following command:
[root@linuxnix ~]# yum install git -y Loaded plugins: fastestmirror, langpacks base | 3.6 kB 00:00:00 epel/x86_64/metalink | 8.2 kB 00:00:00 extras | 3.4 kB 00:00:00 puppetlabs-pc1 | 2.5 kB 00:00:00 updates | 3.4 kB 00:00:00 Loading mirror speeds from cached hostfile * base: ftp.iitm.ac.in * epel: mirror1.ku.ac.th * extras: ftp.iitm.ac.in * updates: ftp.iitm.ac.in Resolving Dependencies --> Running transaction check ---> Package git.x86_64 0:22.214.171.124-6.el7_2.1 will be updated --> Processing Dependency: git = 126.96.36.199-6.el7_2.1 for package: perl-Git-188.8.131.52-6.el7_2.1.noarch ---> Package git.x86_64 0:184.108.40.206-12.el7_4 will be an update --> Running transaction check ---> Package perl-Git.noarch 0:220.127.116.11-6.el7_2.1 will be updated ---> Package perl-Git.noarch 0:18.104.22.168-12.el7_4 will be an update --> Finished Dependency Resolution Dependencies Resolved ==================================================================================================================================== Package Arch Version Repository Size ==================================================================================================================================== Updating: git x86_64 22.214.171.124-12.el7_4 updates 4.4 M Updating for dependencies: perl-Git noarch 126.96.36.199-12.el7_4 updates 53 k Transaction Summary ==================================================================================================================================== Upgrade 1 Package (+1 Dependent package) Total download size: 4.4 M Downloading packages: updates/7/x86_64/prestodelta | 605 kB 00:00:02 Delta RPMs reduced 53 k of updates to 26 k (50% saved) (1/2): perl-Git-188.8.131.52-6.el7_2.1_184.108.40.206-12.el7_4.noarch.drpm | 26 kB 00:00:02 (2/2): git-220.127.116.11-12.el7_4.x86_64.rpm | 4.4 MB 00:00:42 ------------------------------------------------------------------------------------------------------------------------------------ Total 105 kB/s | 4.4 MB 00:00:43 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : perl-Git-18.104.22.168-12.el7_4.noarch 1/4 Updating : git-22.214.171.124-12.el7_4.x86_64 2/4 Cleanup : perl-Git-126.96.36.199-6.el7_2.1.noarch 3/4 Cleanup : git-188.8.131.52-6.el7_2.1.x86_64 4/4 Verifying : git-184.108.40.206-12.el7_4.x86_64 1/4 Verifying : perl-Git-220.127.116.11-12.el7_4.noarch 2/4 Verifying : perl-Git-18.104.22.168-6.el7_2.1.noarch 3/4 Verifying : git-22.214.171.124-6.el7_2.1.x86_64 4/4 Updated: git.x86_64 0:126.96.36.199-12.el7_4 Dependency Updated: perl-Git.noarch 0:188.8.131.52-12.el7_4 Complete! [root@linuxnix ~]#
Install GIT from source:
We’ll now show you how to install it from source. Before you begin, you’ll need to install the software that git depends on. We’ll now install these dependencies with the following commands:
sudo yum groupinstall "Development Tools" sudo yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
The development tools package group consists of tools like gcc which are essential in compiling and building binaries from source code.
I’ve downloaded git using the git repository on github.
[root@linuxnix ~]# ls -l git-master.zip -rw-r--r--. 1 root root 8615986 Dec 30 03:51 git-master.zip [root@linuxnix ~]#
Let’s unzip it.
[root@linuxnix ~]# unzip git-master.zip
Now that the file has been extracted, let’s take a look inside the directory.
[root@linuxnix git-master]# pwd /root/git-master [root@linuxnix git-master]# ls | wc -l 395
Once we are in the source folder, we can begin the source build process. We can perform pre-build checks like software dependencies and hardware configurations with the configure script that is generated by make configure.
This script will also use a –prefix to declare /usr/local as the appropriate destination for the new binary and will create a Makefile to be used in the following step. We’ll generate the Makefile with the following commands:
make configure ./configure --prefix=/usr/local
Makefiles are scriptable configuration files that are processed by the make utility. Our Makefile will tell make how to compile a program and link it to our CentOS installation so that we can execute the program properly. With a Makefile in place, we can now execute make install to compile the source code into a working program and install it on our server. We’ll now execute the make install command as follows to install the required packages on the system.
Once the install completes, we can verify that we now have git installed by checking it’s version.
[root@linuxnix ~]# which git /usr/local/bin/git [root@linuxnix ~]# [root@linuxnix ~]# git --version git version 2.16.0-rc0 [root@linuxnix ~]#
In this article, we showed you how to install git via the yum package manager and also from source. We also explained the need for version control systems and the different advantages they provide. In our next article, we’ll show how to configure git before we may start using it.
Latest posts by Sahil Suri (see all)
- Google Cloud basics: Activate Cloud Shell - May 19, 2021
- Create persistent swap partition on Azure Linux VM - May 18, 2021
- DNF, YUM and RPM package manager comparison - May 17, 2021
- Introduction to the aptitude package manager for Ubuntu - March 26, 2021
- zypper package management tool examples for managing packages on SUSE Linux - March 26, 2021