How to Install Git on Ubuntu 26.04 | Step by Step Guide

Programming

By Jennifer Webb

Updated on Jul 09, 2026

How to Install Git on Ubuntu 26.04 | Step by Step Guide

In this tutorial, learn how to install Git on Ubuntu 26.04 with simple commands. Configure your username and email, verify Git, update it, and fix common errors.

Git is one of the first tools most developers install on a new Ubuntu system. It is used to track changes in files, manage source code, work with other developers, and maintain a history of everything changed inside a project.

If you plan to clone repositories, manage application code, or work with services such as GitHub and GitLab, you will need Git installed on your system.

Prerequisites

Before starting, make sure you have:

  • A system running Ubuntu 26.04 dedicated server

  • A user account with sudo privileges

  • Access to the terminal

  • An active internet connection

You can check your Ubuntu version with:

lsb_release -a

You should see Ubuntu 26.04 in the output.

Step 1: Update the Package Index

Start by refreshing the local package index:

sudo apt update

This command downloads the latest package information from the repositories configured on your Ubuntu system.

Step 2: Install Git on Ubuntu 26.04

Install Git using the APT package manager:

sudo apt install git -y

The -y option automatically confirms the installation prompt.

APT will download Git and any required dependencies, then install them on your system.

For most Ubuntu 26.04 users, this is the recommended installation method because Git can be managed and updated through the normal Ubuntu package system.

Step 3: Verify the Git Installation

Once the installation finishes, check the installed version:

git --version

You should receive output similar to:

git version 2.x.x

The exact version number may be different depending on the current package available in the Ubuntu 26.04 repositories.

If the command prints a Git version, the installation was successful.

You can also check where the Git executable is installed:

which git

A normal installation should return:

/usr/bin/git

Step 4: Configure Your Git Username

Git records an author name with each commit. Set your global username with:

git config --global user.name "Your Name"

For example:

git config --global user.name "John Smith"

Use the name you want to appear in your Git commit history.

Step 5: Configure Your Git Email Address

Next, set your email address:

git config --global user.email "[email protected]"

For example:

git config --global user.email "[email protected]"

If you plan to push code to GitHub or another Git hosting service, you may want to use the email address associated with that account.

Step 6: Set the Default Branch Name

Many modern Git workflows use main as the default branch name.

You can configure it globally with:

git config --global init.defaultBranch main

Now, when you create a new repository with git init, Git will use main as the initial branch name.

Step 7: Check Your Git Configuration

View your current Git configuration:

git config --list

You should see entries similar to:

user.name=John Smith
[email protected]
init.defaultbranch=main

For a more focused check, run:

git config --global --list

This displays the settings stored in your global Git configuration.

You can also check individual values:

git config --global user.name

And:

git config --global user.email

Step 8: Test Git with a New Repository

Now create a small test project to confirm that Git is working correctly.

Create a new directory:

mkdir git-test

Move into it:

cd git-test

Initialize a new Git repository:

git init

You should see a message confirming that an empty Git repository has been initialized.

Create a test file:

echo "Hello Git" > README.md

Check the repository status:

git status

Git should show README.md as an untracked file.

Add the file to the staging area:

git add README.md

Create your first commit:

git commit -m "Initial commit"

Now check the commit history:

git log --oneline

You should see your first commit in the output.

At this point, Git is installed, configured, and working correctly.

How to Update Git on Ubuntu 26.04

If Git was installed through APT, refresh the package index first:

sudo apt update

Then upgrade the Git package:

sudo apt install --only-upgrade git

You can check the version again with:

git --version

Keep in mind that the Ubuntu repositories provide the Git version maintained for your Ubuntu release. This may not always be the newest upstream Git release published by the Git project.

Optional: Install a Newer Stable Git Version

For most users, the Ubuntu repository version is the better choice. It is simple to maintain and integrates cleanly with the system package manager.

If you specifically need a newer stable Git release than the version available in the standard Ubuntu repositories, the Git project points Ubuntu users to the Git Core PPA.

First, install the repository management tools:

sudo apt install software-properties-common -y

Add the Git Core PPA:

sudo add-apt-repository ppa:git-core/ppa

Refresh the package index:

sudo apt update

Install or upgrade Git:

sudo apt install git -y

Verify the installed version:

git --version

Do not add a third party repository. Use this method when you actually need a newer Git release.

How to Uninstall Git

If you no longer need Git, remove it with:

sudo apt remove git

To remove Git and its package configuration files:

sudo apt purge git

You can also remove dependencies that are no longer required:

sudo apt autoremove

Your personal Git configuration file may still remain in your home directory.

You can check it with:

ls -la ~/.gitconfig

If you want to remove that configuration as well:

rm ~/.gitconfig

Only run this command if you are sure you no longer need your saved global Git settings.

Conclusion

You have successfully installed Git on Ubuntu 26.04 and configured the basic settings required for everyday development work.

For most users, the complete setup comes down to a few commands:

sudo apt update
sudo apt install git -y
git --version
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git config --global init.defaultBranch main

Git is now ready to use for local projects, cloned repositories, and remote development workflows. You can create repositories with git init, clone existing projects with git clone, and start tracking changes in your code.