How to install git


In this article you will learn how to install git under Linux / UNIX environments.

 

Note: When this article was written (May 2013) we are using Debian based operating system Ubuntu 12.04 LTS. This works under Ubuntu 10.04 LTS, Ubuntu 13, CentOS / RHEL / Redhat Enterprise Linux, Debian 6 and Debian 7.

 

What is GIT?

GIT is a distributed version and revision control system in the software development world. GIT allows us to handle large amounts of data effectively by storing it on the local system. The makes for a distributed nature, as every copy is on the local system as well as the server and it makes it very fast.

GIT is developed by the father of Linux Kernel famously known was “Linus Torvals” however there are many other developers whom they shall be appreciated for their great work.

 

You either need to run commands as root and ignore sudo in the commands below or if you are logged in with your user it should be a sudo user.

 

sudo apt-get update

sudo apt-get upgrade

 

The first command is updating software update repositories. The second command is for upgrading software packages installed against the updated repositories.

 

Install GIT either two ways: using “apt-get” or if you want latest stable build of the GIT we will download, compile and install as well.

 

Now, start with the installation of “GIT” by using the command below:

sudo apt-get install git

 

After then download installed you now have GIT installed. You can skip the below steps of downloading, compilation and installation and move directly to the configuration step.

 

How to install latest stable GIT from source:

We recommend installation of the dependencies which you will require when you will compile GIT from the tarball source

 

sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev build-essential

 

Once above dependencies and packages are installed you canmove on to how to download and install the latest stable release of GIT:

You can download latest stable release of GIT from Google use using the URL https://code.google.com/p/git-core/downloads/list

At the time of writing this article, the latest stable release version of GIT is “1.8.2.3”

 

Download it by using below command:

wget http://git-core.googlecode.com/files/git-1.8.2.3.tar.gz

 

When the download completes, extract the tarball.

 

tar xvzf git-1.8.2.3.tar.gz

 

Change the directory extracted.

 

cd git-1.8.2.3

 

Install GIT under /usr/local and our user which we are logged in with and also available for all global Linux/UNIX users. Commands below:  

 

make prefix=/usr/local all

sudo make prefix=/usr/local install

 

If you want to update to the latest stable release on the Google code server you can use GIT itself.

 

git clone git://git.kernel.org/pub/scm/git/git.git

 

After GIT is installed―either you preferred to install using “apt-get” or download and compile from source― you need to create your username and email for the “gitconfig” file.

You can access your “gitconfig” file “.gitconfig” in your home directory “~”

 

Edit the file “.gitconfig” in home directory “~”

 

vim ~/.gitconfig

 

Add the below content to this file:

 

git config --global user.name "ShellWays"

git config --global user.email admin@shellways.com

 

Save and exit the file.

 

To view all of your settings and the username and email you just set in the file “.gitconfig” use below command.

 

git config --list

 

Congrats! You have successfully installed GIT on your Linux/UNIX server / machine.

 

Verify your installation was complete by using the command below:

 

git --version

 

Please note, we installed the latest stable release at the time of this article (version “1.8.2.3”).

Posted in
Last update:
2015-12-03 20:39
Average rating:0 (0 Votes)