Install Git on Ubuntu

Git is an open-source distributed version control system that is available for everyone at zero cost. It is designed to handle minor to major projects with speed and efficiency. It is developed to co-ordinate the work among programmers. The version control allows you to track and work together with your team members at the same workspace.

Git is the most common source code management (SCM) and covers more users than earlier VCS systems like SVN. Let’s understand how to install Git on your Ubuntu server.

I have done this installation on Ubuntu 16.04 LTS. But the given commands should also work with the other versions.

Below are the steps to install the Git on Ubuntu server:

Step1: Start the General OS and Package update

First of all, we should start the general OS and package updates. To do so, run the below command:

$ apt-get update
[/code]

Now we have started the general OS and package updates. After this, we will run the general updates on the server so that we can get started with installing Git. To do so, run the following commands:

Step2: Install Git

To install Git, run the below command:

$ apt-get install git-core
[/code]

The above command will install the Git on your system, but it may ask you to confirm the download and installation.

Step3: Confirm Git the installation

To confirm the installation, press ‘y‘ key on the editor. Now, Git is installed and ready to use.

When the central installation done, first check to ensure the executable file is set up and accessible. The best way to do this is the git version command. It will be run as:

$ git –version
[/code]

Output:

git version 2.24.0
[/code]

Step4: Configure the Git for the First use

Now you can start using Git on your system. You can explore many features of the version control system. To go with Git, you have to configure the initial user access process. It can be done with the git config command.

Suppose I want to register a user whose user name is “javaTpoint” and email address is “Javatpoint@xyz”, then it will be done as follows:

To register a username, run the below command:

$ git config –global user.name “maixuanviet”
[/code]

To register an email address for the given author, run the below command:

$ git config –global user.email “maixuanviet.com@gmail.com”
[/code]

Now, you have successfully registered a user for the version control system.

It’s important to understand that the git config tool works on a user according to the user. For example, if we have a user “john” registered on Git. Then there can be another user “Mike” on the same machine registered on Git. To do this, Mike must run the same command from his user account. The commits made by both the users will be done under their details in Git.