Linux Desktop GuideLinux Tutorials

How to Install Git on Ubuntu 24.04 — Complete Guide (apt, PPA, and Build from Source)

Installing Git on Ubuntu 24.04 is a common first step for developers, DevOps engineers, and system administrators who need reliable version control. This guide shows multiple, practical ways to install Git on Ubuntu 24.04 — using the default apt packages, the official Git PPA for cutting-edge releases, and building from source when you need a specific version. Each method includes verification, configuration steps for commit identity, and troubleshooting tips so you can quickly get a stable Git environment on both desktop and server installations. Follow the appropriate section for your needs and learn how to keep Git updated and integrated into your workflow.

Check if Git Is Already Installed

Before installing anything, check whether Git is already present on your system and which version is installed. This helps you decide whether the repository-provided version is sufficient or you need a newer release from the PPA or to compile from source.

git --version

git version 2.43.0

The command prints the currently installed Git version. If you see an error like command not found, Git is not installed. The example output above shows a typical repository version on Ubuntu 24.04; yours may differ. No flags are required for this command.

Install Git Using Apt (Recommended for Most Users)

Installing Git via apt is the simplest and most maintainable option for most environments. It installs a well-tested release that integrates with Ubuntu's package management, security updates, and dependency tracking. Use this method for production servers and general desktop usage unless you need a newer feature set than the distribution provides.

sudo apt update

Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [120 kB]
Fetched 120 kB in 1s (120 kB/s)
Reading package lists... Done

The sudo apt update command refreshes local package metadata. The output shows repositories contacted and confirms that package lists were updated. No additional flags are required for the update step.

sudo apt install git -y

Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  git
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 21.6 MB of archives.
After this operation, 76.2 MB of additional disk space will be used.
Fetched 21.6 MB in 2s (10.8 MB/s)
Selecting previously unselected package git.
(Reading database ... 150000 files and directories currently installed.)
Preparing to unpack .../git_2.43.0-1_amd64.deb ...
Unpacking git (2.43.0-1) ...
Setting up git (2.43.0-1) ...
Processing triggers for man-db (2.10.2-1) ...

Use -y to accept prompts automatically when scripting or automating. The apt installer output shows package download and installation progress, finishing with package setup steps.

Install a Newer Git Using the Official Git PPA

If you need features introduced after the Ubuntu release you run, the Git Maintainers PPA provides newer stable releases. Adding the PPA and installing from it is straightforward; it replaces the repository package with the PPA package and keeps updates available via apt.

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

 You are about to add the following PPA:
 Maintainers of git packages for Ubuntu.
 More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa
Press Enter to continue or Ctrl+C to cancel

The add-apt-repository command registers the PPA with your system. The interactive output requests confirmation; when automating you can pass --yes to skip the prompt. After adding the PPA, you should run sudo apt update and then install Git as shown in the apt section.

sudo apt update

Hit:1 http://ppa.launchpad.net/git-core/ppa/ubuntu jammy InRelease
Get:2 http://archive.ubuntu.com/ubuntu jammy-updates InRelease [120 kB]
Reading package lists... Done

After adding the PPA, update package lists again so apt recognizes packages from the new source.

sudo apt install git -y

Reading package lists... Done
Building dependency tree... Done
The following additional packages will be installed:
  git-man liberror-perl
Suggested packages:
  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk
The following NEW packages will be installed:
  git git-man liberror-perl
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 24.0 MB of archives.
After this operation, 95.0 MB of additional disk space will be used.
Fetched 24.0 MB in 3s (8.0 MB/s)
Unpacking git (2.52.0-1~ppa1) ...
Setting up git (2.52.0-1~ppa1) ...
Processing triggers for man-db (2.10.2-1) ...

The PPA package output indicates the installed Git version from the PPA (example here: 2.52.0). Use the PPA when you require newer Git features or bug fixes that are not yet available in the Ubuntu base repositories.

Build and Install Git from Source (Advanced)

Building Git from source is the most flexible approach and is appropriate when you need a very specific version, want custom build options, or need to test changes. It requires installing build dependencies and is not managed by apt, so updates must be performed manually.

sudo apt install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext -y

Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  build-essential libexpat1-dev libssl-dev libcurl4-gnutls-dev gettext
0 upgraded, 5 newly installed, 0 to remove and 0 not upgraded.
Need to get 12.3 MB of archives.
After this operation, 56.4 MB of additional disk space will be used.
Fetched 12.3 MB in 2s (6.2 MB/s)
Selecting previously unselected package build-essential.
(Reading database ... 150200 files and directories currently installed.)
Preparing to unpack .../build-essential_12.9ubuntu1_amd64.deb ...
Unpacking build-essential (12.9ubuntu1) ...
Setting up build-essential (12.9ubuntu1) ...
Processing triggers for man-db (2.10.2-1) ...

Install required development packages including compilers and libraries Git links against. The list above is representative; additional packages may be required depending on the Git version and optional features (e.g., GUI tools).

wget -c https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.52.0.tar.gz -O /tmp/git-2.52.0.tar.gz

--2026-03-03 12:00:00--  https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.52.0.tar.gz
Resolving mirrors.edge.kernel.org (mirrors.edge.kernel.org)... 151.101.0.133
Connecting to mirrors.edge.kernel.org (mirrors.edge.kernel.org)|151.101.0.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10500000 (10M) [application/x-gzip]
Saving to: '/tmp/git-2.52.0.tar.gz'

/tmp/git-2.52.0.tar.gz 100%[==================================>] 10.02M  5.01MB/s    in 2.0s

2026-03-03 12:00:03 (5.01 MB/s) - '/tmp/git-2.52.0.tar.gz' saved [10500000/10500000]

The wget -c flag enables continuation of partially downloaded files. The output shows the download progress and confirms the tarball was saved to /tmp.

sudo tar -xzf /tmp/git-2.52.0.tar.gz -C /usr/src

Use tar with -xzf to extract a gzipped tarball. The example above omits verbose output for brevity; extraction places the source into /usr/src/git-2.52.0.

cd /usr/src/git-2.52.0 && sudo make prefix=/usr/local all

make configure
make all
Built git (documentation omitted in example)

This command compiles Git. The prefix=/usr/local sets the installation prefix so that Git installs into /usr/local/bin (avoiding overwriting apt-managed /usr/bin files). The build output is abbreviated here; a full build shows compilation steps and progress.

sudo make prefix=/usr/local install

Installing git to /usr/local/bin
Installed: /usr/local/bin/git
Installed: /usr/local/libexec/git-core/git-remote-https
Installed: /usr/local/share/man/man1/git.1

The install step places compiled binaries and man pages under /usr/local. Because this bypasses apt, you must manually manage upgrades and removals. Confirm the PATH includes /usr/local/bin so the new git is preferred over the distribution package.

Verify the Installation and Path Priority

After installing by any method, verify the active Git binary and ensure your PATH uses the intended install location. This avoids surprises when both apt and a manual install exist on the same host.

which git

/usr/local/bin/git

The which command reveals the full path to the git binary that will run when you execute git. If it shows /usr/bin/git, you are using the distribution package; /usr/local/bin/git indicates a source-built install is active. Adjust PATH or remove the package accordingly.

git --version

git version 2.52.0

Confirm the installed Git version. This final check ensures the version matches the method you used (apt, PPA, or compiled). Use this to validate upgrades or post-install changes.

Configure Git User Identity and Helpful Defaults

Configure your global identity and common defaults so commits are attributed properly and your workflow is consistent. These settings are stored in ~/.gitconfig and can be overridden per-repository using the same commands without the --global flag.

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

The git config command sets the Git identity; it produces no output on success. Replace “Your Name” with your real name as you want it to appear in commits.

git config --global user.email "you@example.com"

Set your email so commits are associated with the correct address. This is essential for services like GitHub, GitLab, and others to map commits to your online account.

git config --global core.editor nano

Configure a default editor for commit messages; here we set nano. You can use vim, code --wait (for VS Code), or any editor available on your system.

git config --list

user.name=Your Name
user.email=you@example.com
core.editor=nano
color.ui=auto

The git config –list output displays current Git configuration values in effect, including global settings and any system or repository overrides. Use this to verify your configuration.

Troubleshooting and Common Issues

Common problems include PATH priority issues (source-built git overshadowed by apt package), missing build dependencies when compiling, and SSL/curl errors when interacting with remotes. Resolve PATH issues by ensuring /usr/local/bin appears before /usr/bin in your PATH or by removing the distribution package with sudo apt remove git if you prefer the manually built version. For build problems, install missing -dev packages noted in configure or make error messages. When hitting authentication errors with remotes, confirm your SSH keys or HTTPS credentials and consider credential helpers for improved security and convenience.

Conclusion

Installing Git on Ubuntu 24.04 can be adapted to your needs: use apt for stability and easy maintenance, the Git PPA for newer stable releases, or compile from source when you need a specific version or custom build options. After installation, verify the installed binary, configure your user identity, and test cloning and pushing to a remote to ensure everything is functioning. Following this guide gives you a clear checklist for installation, configuration, and troubleshooting to keep Git running reliably on both desktop and production systems.

One Comment

  1. Great guide — the section on the official Git PPA was super helpful; I’d also suggest adding a quick step on configuring git user.name/user.email and generating an SSH key after installing Git on Ubuntu 24.04.

Komentariši

Vaša email adresa neće biti objavljivana. Neophodna polja su označena sa *