Ubuntu

Install Git on Ubuntu 22.04

Git is a version control or source code management system that efficiently and with great speed manages small to very complex projects. This is an open-source system that is free to use. Git keeps track of changes in the source code and allows numerous developers to work on a project in a non-linear fashion.

Git is user-friendly, therefore, can be learned quickly. Moreover, its fast speed, low-cost local branching, numerous workflows, and appropriate staging areas make it stand out amongst other similar platforms such as CVS, Subversion, ClearCase, and Perforce.

In this blog, we have discussed how you can install Git on the newest Ubuntu release which is Ubuntu 22.04.

How to install Git on Ubuntu 22.04

We have summed up for you all steps that will help in the successful installation of git on Ubuntu 22.04.

Step 1: Update the system

Before installing Git make sure your system is up to date. To verify this use the following commands.

$ sudo apt update

$ sudo apt upgrade -y

Output

Now let’s upgrade the system.

Step 2: Install git

Now check if Git is already installed on the system or not.

$ git --version

Output

As indicated in the output the git version is not installed on the system, therefore, now we will install by running the below-given command.

$ sudo apt install git

Output

Step 3: Verify Installation

Now to verify the successful installation of git use this command once again.

$ git --version

Output

Git has been successfully installed on Ubuntu 22.04.

Below we will brief you on how to set up a user account and make an empty repository using Git.

How to set up an account and repository on Git Ubuntu 22.04

In order to make a user account on Git you have to provide a username and an email and this can be done using the following commands.

Step 1: Provide a username

Use the command given below to provide a username

$ git config --global user.name "INSERT YOUR NAME"

Step 2: Provide an email address

The email address is provided using this command.

$ git config --global user.email "INSERT YOUR EMAIL"

Step 3: Create a repository

Now the account has been set up, we will now generate a repository.

$ mkdir sample-directory -p

The directory has been created with success.

Step 4: Navigate to the directory

Now using the following command navigate to the newly-created directory.

$ cd sample-directory

Step 5: Initialize Git

After navigating to the directory, use the initialization command to create a hidden git directory that will store history, configuration, etc

$ git init

Step 6: List the content to verify

In addition, if you wish to see the content inside the directory then use the command given below.

$ ls -a .git

Below we have attached a screenshot that displays the creation of an account and the generation of an empty git repository.

A git user account and repository has been created successfully.

Conclusion

In order to install Git on Ubuntu 22.04 first upgrade your system using the commands; $ sudo apt update, and $ sudo apt upgrade -y. Then install git through the command $ sudo apt install git. Now to validate whether Git was successfully installed or not using the command; $ sudo git –version. Follow these simple steps and you will install Git on your Ubuntu 22.04 with great ease.

About the author

Naima Aftab

I am a software engineering professional with a profound interest in writing. I am pursuing technical writing as my full-time career and sharing my knowledge through my words.