How to Install Git on Ubuntu 24.04 LTS
Learn how to install git on ubuntu 24.04 LTS via official APT repositories, the Git maintainers PPA, source compilation, and Git configuration.

5 min read
Learn how to install git on ubuntu 24.04 LTS via official APT repositories, the Git maintainers PPA, source compilation, and Git configuration.
- Prerequisites and Supported Releases
- Step 1: Checking for an Existing Git Installation
- Step 2: Method 1: Installing Git via Default APT Repositories
Git is the industry-standard distributed version control system (DVCS) that underpins modern collaborative software engineering, CI/CD deployment pipelines, and open-source ecosystems.
Engineered by Linus Torvalds for high performance, non-linear development, and cryptographic integrity, Git allows teams to track changes, maintain feature branches, and merge code seamlessly.
Whether you are building web applications, maintaining system administration scripts, or orchestrating cloud infrastructure, Git is the first tool you must configure on any development environment.
In this guide, we walk through how to install git on ubuntu 24.04 LTS using default Ubuntu repositories, installing cutting-edge releases via the Git Maintainers PPA, compiling from source, and configuring user credentials.
Comprehensive step-by-step developer tutorial on how to install and configure the Git distributed version control system on Ubuntu 24.04 LTS (Noble Numbat). Explains installing Git via the default APT repository, getting the latest upstream release via the official Git Maintainers PPA, compiling Git from source code for maximum customization, configuring global user identity, and generating secure Ed25519 SSH keys for GitHub and GitLab authentication.
Prerequisites and Supported Releases
This guide is thoroughly verified on Ubuntu 24.04 LTS (Noble Numbat) & Ubuntu 22.04 LTS. The instructions apply cleanly to cloud instances (AWS EC2, Google Compute Engine, DigitalOcean, Hetzner), bare-metal servers, and local virtual machines.
Before proceeding, ensure you have the following requirements satisfied:
- A computer or server running Ubuntu 24.04 LTS or Ubuntu 22.04 LTS.
- A user account with
sudoadministrative privileges. - Access to a command-line terminal shell.
Step 1: Checking for an Existing Git Installation
Before installing Git, check whether a version is already installed on your system.
Run the git --version command in your terminal:
If Git is already installed, the command outputs the release version; if not, your shell prompts you with installation instructions:
# Check installed Git version:
git --version
# If installed: git version 2.43.0
# If missing: Command 'git' not found, but can be installed with...
Step 2: Method 1: Installing Git via Default APT Repositories
The fastest and most stable method for installing Git on Ubuntu is using the official APT repository.
Ubuntu 24.04 provides a well-tested, rock-solid release of Git directly in its main software component.
Update your local repository cache and install the git package:
# Update APT package lists:
sudo apt update
# Install Git via APT:
sudo apt install -y git
# Verify installed Git version and executable path:
git --version
which git
# Output confirms: /usr/bin/git
Step 3: Method 2: Installing Latest Git via the Git Maintainers PPA
While Ubuntu's default repository package is stable, it remains frozen at the version shipped during the initial Ubuntu release.
If you require the absolute latest upstream features, bug fixes, or performance enhancements, install Git from the official Git Core PPA maintained directly by the Ubuntu Git packaging team.
Add the PPA to your system and install the upgraded package:
# Install software-properties-common if missing:
sudo apt install -y software-properties-common
# Add the official Git Core Team PPA:
sudo add-apt-repository -y ppa:git-core/ppa
# Refresh repository cache and upgrade Git:
sudo apt update
sudo apt install -y git
# Confirm that Git was updated to the latest upstream release:
git --version
Step 4: Method 3: Compiling Git from Source Code
Compiling Git from source provides total control over build configurations, allows you to link specific cryptographic libraries, and ensures you have the latest commit directly from the developers.
First, install the necessary compilation build tools and development libraries:
Download the source tarball from GitHub or kernel.org, compile, and install it into /usr/local:
# Install source compilation dependencies:
sudo apt update
sudo apt install -y make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev \
libexpat1-dev gettext unzip build-essential
# Download desired Git release tarball:
cd /tmp
wget https://github.com/git/git/archive/refs/tags/v2.45.0.tar.gz -O git.tar.gz
tar -xf git.tar.gz
cd git-2.45.0
# Compile and install Git:
make prefix=/usr/local all -j $(nproc)
sudo make prefix=/usr/local install
# Verify newly compiled binary:
/usr/local/bin/git --version
Step 5: Configuring Git User Identity and Global Defaults
After installing Git, configure your name and email address before committing any code.
Git embeds this information immutably into every commit you create, ensuring auditability across codebases.
Use the git config command to set your global user parameters and configure modern defaults like the default main branch:
# Configure global user name and email:
git config --global user.name "Rajesh Rai"
git config --global user.email "[email protected]"
# Set default initial branch name to main:
git config --global init.defaultBranch main
# Configure preferred text editor (e.g., nano or vim):
git config --global core.editor nano
# Review all active global Git configurations:
git config --list --show-origin
Step 6: Generating SSH Keys for GitHub and GitLab Authentication
Major code hosting platforms—including GitHub, GitLab, and Bitbucket—require SSH key authentication or personal access tokens rather than plaintext account passwords.
Generate a secure Ed25519 SSH key pair using ssh-keygen:
Display your public key and paste it into your GitHub or GitLab SSH Settings:
# Generate an Ed25519 SSH key pair:
ssh-keygen -t ed25519 -C "[email protected]"
# Press Enter to accept default location (~/.ssh/id_ed25519)
# Start ssh-agent and register your private key:
eval "$(ssh-agent -s)"
ssh-add ~/.ssh/id_ed25519
# Display public key to copy to your GitHub/GitLab account:
cat ~/.ssh/id_ed25519.pub
# Test connection to GitHub:
ssh -T [email protected]
# Expected confirmation: Hi username! You've successfully authenticated...
Troubleshooting and Common Errors
When configuring Ubuntu servers, unexpected permission errors, network timeouts, or lock contention can occur. Review these common issues and verified resolutions:
git: command not found
Cause: Git is not installed on the system, or /usr/bin is missing from the shell $PATH.
Resolution: Install Git via APT: sudo apt update && sudo apt install -y git.
sudo apt update && sudo apt install -y git
fatal: unable to auto-detect email address (got 'user@hostname')
Cause: Attempting to create a git commit before configuring user.name and user.email.
Resolution: Configure your global user identity: git config --global user.name 'Name' and git config --global user.email '[email protected]'.
git config --global user.name "Your Name" && git config --global user.email "[email protected]"
Permission denied (publickey) when pushing to GitHub/GitLab
Cause: Your SSH public key is not added to your hosting account, or the ssh-agent is not running.
Resolution: Add your ~/.ssh/id_ed25519.pub key to your account settings and verify with ssh -vT [email protected].
ssh -T [email protected]
Security Best Practices and Hardening
Protect your SSH private keys (~/.ssh/id_ed25519) with a strong passphrase and never share or commit private keys to repositories.
Enable commit signature verification using GPG or SSH keys (git config --global commit.gpgsign true) to guarantee author authenticity.
Never store plaintext API tokens or database passwords inside Git repositories; use environment variables or secret managers.
Related Ubuntu Tutorials and Documentation
Deepen your Linux system administration skills with our related production-tested guides:
- How to Add APT Repository in Ubuntu 24.04 and 22.04 — Learn how to manage software PPAs and signed-by repository keys.
- How to Enable SSH on Ubuntu — Configure OpenSSH server, secure key authentication, and firewalls.
- Initial Server Setup on Ubuntu 24.04 LTS — Essential baseline hardening and developer environment setup.
Authoritative References and Official Documentation

The Linux Command Line, 2nd Edition: A Complete Introduction
Frequently Asked Questions
Quick answers to common questions and configurations
ppa:git-core/ppa is the best choice.~/.gitconfig (or ~/.config/git/config), system-wide configurations in /etc/gitconfig, and repository-specific settings in .git/config.git config --list --show-origin to see all applied configuration directives and the exact files they are defined in.Editorial Disclosure: Website Vidya is supported by our readers. When you purchase hosting, tools, or software through our verified partner links, we may earn an affiliate commission at no extra cost to you. We only recommend solutions we trust and rigorously verify.
Rajesh Ray
I’m Rajesh Rai, a full-stack developer, Linux administrator, and technology enthusiast passionate about making complex technology easier to understand and use.
Most Read Guides
TrendingUbuntu Server Not Booting? 10 Simple Steps to Fix It Fast
How to Create a 3D Button in HTML and CSS: Easy Steps
How to Install Python and Pip on Ubuntu 24.04 LTS
How to Install Nginx on Ubuntu 24.04
How to Install Python on Ubuntu 24.04 LTS
Related Technical Guides
Tested runbooks, server administration walkthroughs, and troubleshooting guides


Join the Conversation & Perspective
Have thoughts, counterpoints, or reflections on this story? Engage directly with fellow readers and editorial contributors.
No comments on this guide yet. Be the first to share your thoughts or ask a question!