How To Install Git On Centos 7
Publisher: Psychz Networks, February 06,2019Git is a version control system which is designed to support software development projects. With the help of Git, you can keep track of software changes, create versions of files and directories. It is a very useful tool for the developers as it can make sure everyone is working on the same version of code, track changes and maintain progress. Developed on opensource technology, it is intended to run on Linux kernel.
Let us now install Git on our CentOS server.
This can be done in two ways. We will cover both the techniques in this guide.
Method 1: Using YUM Package manager
Using YUM package manager we will install Git from system repositories. We will first run system update with the latest version of packages using YUM command as shown below
# yum update
Once we are sure that the system is up to date, we will install Git by typing the following command:
# yum install git
Once the installation is complete you can check the Git version that is installed using the following command
Method 2: Using the source
In this method, first, we need to install required software dependencies from the default repositories. Also, you would need the utilities that is required to build a binary from source. Use following command in the following order
# yum groupinstall "Development Tools"
# yum install gettext-devel openssl-devel perl-CPAN perl-devel zlib-devel
Once the dependencies are installed you need to download the latest version of Git from their official Git release page and grab the latest version
Once the download is complete, we can unpack the source archive using tar.
# tar -zxf git.tar.gz
z decompresses the archive (since all .gz files are compressed)
x extracts the individual files and folders from the archive
f tells tar that we are declaring a filename to work with
We'll need to move to that folder to begin configuring our build. You can use a wildcard (*) to save us some trouble in moving to that folder just like shown below.
# cd git-*
Now we begin with source build process with pre-build checks for software and hardware dependencies.
We can check this with the configure script that is generated by make configure. This script will also use a --prefix to declare /usr/local (the default program folder for Linux platforms) as the appropriate destination for the new binary, and will create a 'Makefile' to be used in the following step.
# make configure
# ./configure --prefix=/usr/local
With a Makefile in place, we can now execute make install (with sudo privileges) to compile the source code into a working program and install it to our server:
# make install
NOTE: 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.
Git should now be built and installed on your CentOS 7 server. To double-check that it is working correctly, try running Git's built-in version check:
# git --version