How to Install Git on Ubuntu 22.04

Git is a version control system that is employed to manage and supervise software development projects. It is an open-source software that can be freely accessed and utilized on different operating systems including Windows, Linux distributions, macOS, etc.

More specifically, Git is easy to use and handles everything from small-scale to large-scale projects. With advanced features, Git allows you to create new projects, manage existing ones, merge multiple versions, and delete useless files and repositories.

This post aims to empower you with knowledge and skills to install, configure, and use the Git version control system.

How to Install Git on Ubuntu 22.04?

The following steps can be performed to install and initialize Git on Ubuntu 22.04.

Step 1: Update and Upgrade Ubuntu Packages

Before installing a new project on Ubuntu, it is highly recommended to update and upgrade the system packages. Additionally, the command written below will ensure that your system files remain up to date:

sudo apt update && sudo apt upgrade

The above output indicates that the current Ubuntu version is up to date.

Step 2: Install Git via Command-line

After updating packages,  install the Git version control system using the following command. Here, the “-y” option is used for prior confirmation to install Git on your system:

sudo apt install git -y

Resultantly, the Git package has been installed without showing any error.

Step 3: Verify Git Version

After that, check the installed version of Git by executing the below-mentioned command:

git --version

The output of the version command states that currently “Git Version 2.34.1” is installed on your system.

How to Configure the Git Via Terminal?

Following these steps will configure the Git version control system from your Ubuntu terminal.

Step 1: Configure User Name

Set up your “User Name” for Git configuration. Moreover, the below command will add your desired name that can be used globally:

git config --global "Genie"

Step 2: Configure User Email

Execute the following command followed using the user-email to set up the Git system. The user email will also be used globally:

git config --global [email protected]

Step 3: List the Git Configuration

Once you have configured the user name and user email, now run the command to check whether your name and email are configured or not:

git config --list

According to the above-attached snapshot, we have properly configured the Git version control system.

How to Initialize the Git Repository via Command Line?

The below-mentioned steps will guide you to configure and initialize the Git Version Control System from the Ubuntu terminal.

Step 1: Create a New Project

Now, create a new folder/directory for your project. For example, we created a new directory named “Project_Linux” with mkdir command as mentioned below:

mkdir Project_Linux

Step 2: List the Available Projects

Next, run the ls command from the Ubuntu terminal to display the available directories on the local drive:


The above command shows all the available directories including the “Project_Linux”.

Step 3: Get into the New Project Directory

Now, get into the new project directory. This command will enter you into the “Project_Linux”:

cd Project_Linux

Step 4: Initialize the Git Repository

To initialize Git, run the command mentioned below from within the “Project_Linux” directory:

git init

As you can see that the command is properly executed and returns the message “Initialized empty Git repository in /home/linux/Project_Linux/.git/”.

Step 5: Display Git Status

Then, run the command to display the current status of the Git repositories such as branch status, track, and untracked files, commit status, etc:

git status

Here is the message from the git status command that shows the Project_Linux on the master branch and no comments yet.


Git is a version control system that tracks and manages changes, allowing you to keep track of different versions of your project. It will manage and collaborate your code with other developers. It also offers you to create a local copy of your project. You can install Git by executing this single-line command, “sudo apt install git”. This tutorial provided a detailed overview of the installation and configuration of the Git version control system on Ubuntu 22.04.

Print Friendly, PDF & Email