Install GIT on Ubuntu 16.04 within 2 Steps [3 Minutes Tutorial]

Introduction

One of the main thing in development is keeping backup of existing and running version of the software.

I know many of the developers never thought of using a version control system instead, they themselves keeping the backup of the file.

But:

That is not the good way to organize yourself.

You should have a version controlling software where you can always keep track of your changes and if you have made any mistakes, then you can use this version control software to roll back to the previous version and fix the mistake or bug by comparing the code.

Sorry, for such a long sentence.

Here in this tutorial, we are going to see such one of the software for you to keep track and have control over your versions.

What is GIT?

GIT is a version control system widely used by many developers and companies.

Since a lot of development works are carried out based on Ubuntu operating system, we have written this article to benefit the software developers who are using the Ubuntu.

Requirements

Most of our articles, requires you to setup a sudo non root user account to protect your server from unnecessary data loss.

Since many of you running ubuntu server from command prompt, there is a little chance for something to go wrong while installing some software.

here is the tutorial for you to follow to create sudo non root user.

Get 50$ Credit on Vulture Clouds Here and Test the Instruction for free.

Install Git on Ubuntu 16.04

There are two ways available for you to install GIT on ubuntu 16.04.

The first one is installing it from the Ubuntu repository.

This is the simple method and you will love Ubuntu for giving option for you to install most of the software with one command.

Here is the command for that.

$ sudo apt-get update
$ sudo apt-get install git

Thats all. this command will download and install Git on your Ubuntu server.

The second method is installing Git from the source itself.

First, let us update the package index and then install the dependencies for git.

$ sudo apt-get update
$ sudo apt-get install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

Next you have to get the download link. For that, go to this link.

Go to Branch master->then select tags -> select version

Then, click on clone or download and then copy download zip link.

Once you get that link, you have to download the zip file in ubuntu using wget command.

$ wget https://github.com/git/git/archive/v2.18.0.zip -O git.zip

Then, unzip the file using unzip command.

$ unzip git.zip
$ cd git-*

After that, install the package using the below command.

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

Since, this is the latest version, now let us see how to setup Git.

Setup the Git

Here, we have to add our name and email address so that we can get the right message when each time you do commit.

For that, we will use Git config command.

Here are the two commands you need to execute inorder to add the information.

$ git config --global user.name "Name"
$ git config --global user.email "email@mydomain.com"

To see the changes we have made, look use the below command.

$ git config --list

You will get the following output.

user.name=Name
user.email=email@yourdomain.com

When you add this information, it will be stored in the configuration file. Incase, you want change the given information, just open the configuration file and directly edit it.

Here is the command for that.

$ nano ~/.gitconfig

The configuration file will be opened on nano editor.

[user]
    name = Name
    email = email@yourdomain.com

If do not follow the above step, you will get the warning like below one.

[master 0d9d21d] initial project version
 Committer: root 
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email you@example.com

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

These two are essential settings that you have to do.

Thats all, you have done installing and configuring Git on your Ubuntu server.

Conclusion

If you have any errors while execution, let me know them in command.

Dont forget to signup for my tutorials to receive notification for next tutorial when it goes live.

Stay tune with us to learn more about cloud servers.

LIKE THIS ARTICLE?

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Leave a Comment