How to Install Git on Ubuntu 24.04

By 

Published on

3 min read

Install Git on Ubuntu

Git is the world’s most popular distributed version control system used by many open-source and commercial projects. It allows you to collaborate on projects with fellow developers, keep track of your code changes, revert to previous stages, create branches , and more.

Git was originally developed by Linus Torvalds , the creator of the Linux kernel.

This guide covers installing and configuring Git on Ubuntu 24.04 using apt, the Git PPA, or by compiling from source.

Quick Reference

TaskCommand
Install Git (apt)sudo apt install git
Install Git (PPA)sudo add-apt-repository ppa:git-core/ppa && sudo apt install git
Check Git versiongit --version
Set usernamegit config --global user.name "Your Name"
Set emailgit config --global user.email "you@example.com"
View configgit config --list

Installing Git with Apt

This is the quickest way to install Git on Ubuntu.

Check if Git is already installed:

Terminal
git --version

If Git is not installed, you’ll see a “command not found” message. Otherwise, it shows the installed version.

If Git is not installed, use the apt package manager:

Terminal
sudo apt update
sudo apt install git

Verify the installation:

Terminal
git --version

The version of Git in the Ubuntu 24.04 repositories is 2.43.0:

output
git version 2.43.0

You can now start configuring Git.

When a new version of Git is released, you can update using sudo apt update && sudo apt upgrade.

Installing Git from the PPA

The Ubuntu Git Maintainers provide a PPA with the latest stable Git releases. Use this method if you need a newer version than the default repository provides.

Add the PPA and install Git:

Terminal
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

Verify the installation:

Terminal
git --version
output
git version 2.52.0

Installing Git from the Source

The main benefit of installing Git from source is that you can compile any version you want. However, you cannot maintain your installation through the apt package manager.

Install the build dependencies:

Terminal
sudo apt update
sudo apt install libcurl4-gnutls-dev libexpat1-dev cmake gettext libz-dev libssl-dev gcc wget

Visit the Git download page to find the latest version.

At the time of writing, the latest stable Git version is 2.52.0.

If you need a different version, visit the Git archive to find available releases.

Download and extract the source to /usr/src:

Terminal
wget -c https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.52.0.tar.gz -O - | sudo tar -xz -C /usr/src

Navigate to the source directory and compile:

Terminal
cd /usr/src/git-*
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install

The compilation may take some time depending on your system.

For changes to take effect on your current shell, you can either log out and log in or run the following source command:

Terminal
source /etc/environment

Verify the installation:

Terminal
git --version
output
git version 2.52.0

To upgrade to a newer version later, repeat the same process with the new version number.

Configuring Git

After installing Git, configure your username and email address. Git associates your identity with every commit you make.

Set your global commit name and email:

Terminal
git config --global user.name "Your Name"
git config --global user.email "youremail@yourdomain.com"

Verify the configuration:

Terminal
git config --list
output
user.name=Your Name
user.email=youremail@yourdomain.com

The configuration is stored in ~/.gitconfig:

~/.gitconfigconf
[user]
    name = Your Name
    email = youremail@yourdomain.com

You can edit the configuration using git config command or by editing ~/.gitconfig directly.

Conclusion

We covered three ways to install Git on Ubuntu 24.04: using apt, the Git PPA for the latest version, or compiling from source. The default repository provides Git 2.43.0, which is sufficient for most use cases.

For more information, see the Pro Git book .

Linuxize Weekly Newsletter

A quick weekly roundup of new tutorials, news, and tips.

About the authors

Dejan Panovski

Dejan Panovski

Dejan Panovski is the founder of Linuxize, an RHCSA-certified Linux system administrator and DevOps engineer based in Skopje, Macedonia. Author of 800+ Linux tutorials with 20+ years of experience turning complex Linux tasks into clear, reliable guides.

View author page