Вы находитесь на странице: 1из 4

LinuxTechLab.

com

How to install GIT on Linux


(Ubuntu & CentOS)

Originally published on

LinuxTechLab.com
Git is one of the famous, open-source & distributed version controlling system, that is
used for tracking changes in files/code among multiple peoples/locations. Being a
distributed system allows every repository on every system to be a full fledged
repository in itself with complete history & version tracking capabilities.

It was created by Linus Torvalds for Linux kernel development but ever since then it has
been adopted by many big & small organizations alike for version controlling. Git is free
software & distributed under the terms of GNU General Public License.
In this tutorial, we will learn to install git Ubuntu 16.04 & CentOS 7.

( Also read : How to install JENKINS on CenOS 7 )

Installation on CentOS 7
We can install git using 2 methods i.e. either using yum or installing from source. We will
start by using yum for git installation,

YUM method
Just like any other software, we can install git using the yum install command,
$ yum install git

Git package is available with default Centos repositories. Once the git has been installed,
we can check the installed version by executing,
$ git version

Using Source package method


At the time of writing this tutorial, git 2.13.3 is the latest package available. So to
download the latest git package, run
$ wget https://github.com/git/git/archive/v2.13.3.zip

Now unzip the downloaded git.zip using the following command,


$ unzip v2.13.3.zip
$ cd git-2.13.3
Now before we move onto compiling & installing git, we need to make sure that we have
all the required packages ,
$ yum install gcc perl-ExtUtils-MakeMaker
$ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel

Once the packages have been installed, proceed further to compiling the git source
code,
$ make configure
$ ./configure prefix=/usr/local
$ make prefix=/usr/local install

Once the setup has been completed, we can check the git version using the same
command as above i.e.
$ git version

Installation on Ubuntu 16.04


Similarly like CentOS , we can use 2 different methods to install git on Ubuntu. First
method is using apt-get & second is installing from source,

Apt-Get method
To install git using apt-get, run the following commands,
$ sudo apt-get update
$ sudo apt-get install git

Check the installed git version using command ,


$ git version

Source package method


As done with CentOS installation, we will install the required packages for compiling
source code first,
$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev
gettext unzip
next, download the git source file,
$ wget https://github.com/git/git/archive/v2.13.3.zip

Now unzip the downloaded git.zip using the following command,


$ unzip v2.13.3.zip
$ cd git-2.13.3

Next, compile & install the source code


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

Once the setup is done, git will be installed.


In our future tutorials, we will discuss git in a little more depth. If having any
questions/queries regarding this tutorial, please leave them in the comment box below.

If you think we have helped you or just want to support us, please consider these :-
Connect to us: Facebook | Twitter | Google Plus

LinuxTechLab.com

Вам также может понравиться