×


How to install Git on Ubuntu 18.04

Do you want to know more about Git and how to install Git on Ubuntu 18.04?



Git is a version control system to monitor changes made to a repository from a local machine.


Here at Ibmi Media, we help customers install Git on their servers or system as part of our Server Support Services.

Let us see how to get Git installed on a system.

Importance of Version control systems and how to install Git on Ubuntu 18.04?

Version control is very important in keeping track of changes made from a local machine to its repository. This is where Git is essential as it serves as version control system to implement changes from the local machine to the repo and vice versa. Git is primarily used for;

i. Tracking of changes made on the system.
ii. Reverting back to the previous state.
iii. Branch to create an alternate versions of files and directories.

Additionally, with Git changes made in files as well as in the source code is tracked easily.

How to install Git on Ubuntu 18.04?

To install Git on Ubuntu server, first you have to ensure that you are the root user of the server and log in to the server same.
Follow the instruction below to install Git;

1. Git Package installation

As a norm for best practices, before installing any software or tool in Linux, update the system and software packages of the server by running the command below before installing Git;

apt update
apt install git


After Git installation, check the version installed with the command below;

git --version


The output will look like this;

git version 2.17.1


2.  Git Installation from Source

Installing Git from compiling from the software source is a more secure way of installing Git. Although the process takes longer time, it helps to get the most recent release and make the customization more flexible. To do this follow the instructions below;

i. Git have some dependency software which it depends on to work successfully. So to install them, use the command below;

apt update
apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip


ii. After installing the dependencies, head to the official Git repository source via the URL below;

https://github.com/git/git


iii. You will see an option to clone or download the project zip file from the top right hand of the page which you can copy the filename which ends with a .zip extension.
From your server, change directory to /tmp. use the command below;

cd /tmp


iv. Now with the wget command utility, download the Git source file with the command below;

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


iv. Since the file is a zip file, you need to unzip it and move it into the directory with the command below;

unzip gitfile.zip
cd git-*


Next, use the "make" command to make the package and install with the commands below;

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


After this procedures, confirm the install Git by checking its version with the command;

git –version


Need support to install Git? We are available.


Conclusion

Different ways to install Git which enables tracking the changes in source code as well as to track changes made in files.