DEV Community

Cover image for Installing Git on Ubuntu 24.04
Sanskriti Harmukh for Vultr

Posted on with Aashish Chaurasiya Originally published at docs.vultr.com

Installing Git on Ubuntu 24.04

Git is an open-source distributed version control system used to track changes in projects and during software development. Git allows multiple contributors to simultaneously work on a single project, maintain and track the history of all changes. It enables efficient collaboration and allows developers to synchronize changes using Git-compatible platforms such as GitHub, GitLab, and Bitbucket. This guide walks through installing and configuring Git on Ubuntu 24.04. By the end, you'll have the latest Git version installed and configured to work with local and remote repositories in your project environment.

Before you begin, you need access to an Ubuntu 24.04 instance to install Git as a non-root sudo user.


1. Verify the Default Git Version

Git is available by default on Ubuntu 24.04, but the default version may be outdated and not the latest.

1. View the default installed Git version:

$ git --version
Enter fullscreen mode Exit fullscreen mode

Your output should be similar to the one below.

git version 2.43.0
Enter fullscreen mode Exit fullscreen mode

2. Run the Git command and verify that the default help page displays:

$ git
Enter fullscreen mode Exit fullscreen mode

Output:

usage: git [-v | --version] [-h | --help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           [--config-env=<name>=<envvar>] <command> [<args>]

These are common Git commands used in various situations:
........
Enter fullscreen mode Exit fullscreen mode

If Git is unavailable or outdated on your workstation, follow the steps below to install the latest Git version on your instance.

2. Install Git Using APT

Git is available in the default APT package repositories on Ubuntu 24.04.

1. Add the Git PPA to the APT package repository sources:

$ sudo add-apt-repository ppa:git-core/ppa
Enter fullscreen mode Exit fullscreen mode

2. Update the APT package index:

$ sudo apt update
Enter fullscreen mode Exit fullscreen mode

3. Install Git:

$ sudo apt install git -y
Enter fullscreen mode Exit fullscreen mode

This command installs the latest Git version and replaces the default version installed on your system. To install Git and all extra tools, install the git-all package instead.

$ sudo apt install git-all