您的位置:首页 > 运维架构 > Linux

How to install GIT on Linux (Ubuntu & CentOS)

2018-01-27 00:00 495 查看

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

7fe0

Become a Supporter – Make a contribution via PayPal

[paypal_donation_button align=”left” border=”1″]

Linux TechLab is thankful for your continued support.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  git linux