Linux

Installing Git on Ubuntu 22.04/24.04: Complete Guide

This guide will help you install and configure Git on Ubuntu 22.04 LTS or 24.04 LTS. You'll have a working version control system ready for your projects.

Updated at February 15, 2026
5-10 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04 LTSUbuntu 24.04 LTSDebian 11/12

Introduction / Why This Is Needed

Git is a distributed version control system and the de facto standard for software development. Installing Git on Ubuntu is the first and essential step to participating in any project on GitHub, GitLab, or Bitbucket. This guide will walk you through a quick installation from the official repositories and basic configuration so you can immediately start cloning repositories and committing changes.

Prerequisites / Preparation

  • Operating System: Ubuntu 22.04 LTS, 24.04 LTS, or a compatible Debian-based distribution (e.g., Linux Mint).
  • Access Permissions: A user account with sudo privileges to install system packages.
  • Internet: Access to Ubuntu package repositories.
  • Terminal: Any terminal (GNOME Terminal, Konsole, xterm, etc.).

Step 1: Update the Package List

Before installing any new software, it is recommended to update the local package index so your system is aware of the latest available versions.

sudo apt update

This command synchronizes your system with the repositories specified in /etc/apt/sources.list.

Step 2: Install Git

Installing Git from Ubuntu's standard repositories is the simplest and safest method.

sudo apt install git -y

The -y flag automatically confirms the installation prompt. Omit this flag if you prefer to see the confirmation.

Step 3: Verify the Installation

After the installation completes, ensure the git binary is available in your system.

git --version

Expected Output: git version 2.xx.x (the specific version depends on your Ubuntu release).

💡 Tip: If the git command is not found, try closing and reopening your terminal or run hash -r to clear the command cache.

Step 4: Configure Global Settings

Git requires that every commit contains author information. Configure this once for your entire system.

git config --global user.name "Your Full Name"
git config --global user.email "your.email@example.com"

Replace "Your Full Name" and "your.email@example.com" with your actual details. Use the email address associated with your GitHub/GitLab account.

Step 5: Verify the Configuration

Display the saved global settings to confirm they are correct.

git config --global --list

The output should include the lines user.name=Your Full Name and user.email=your.email@example.com.

Verification of Results

  1. Version: git --version displays the current version.
  2. Configuration: git config --list contains the correct user.name and user.email.
  3. Practical Test: Create a test repository.
    mkdir ~/test-git && cd ~/test-git
    git init
    echo "# Test Project" > README.md
    git add README.md
    git commit -m "Initial commit"
    
    If the commit command executes without errors and you see commit information (including your name and email), Git is fully ready for use.

Potential Issues

  • E: Unable to locate package git
    • Cause: The package list was not updated (sudo apt update was not run) or a repository is not enabled.
    • Solution: Run sudo apt update and repeat the installation. Check that the main repository is enabled in /etc/apt/sources.list.
  • Permission denied (publickey) when cloning
    • Cause: This is not a Git installation error. It means you do not have an SSH key configured for server access (GitHub/GitLab).
    • Solution: Set up SSH authentication. See the guide Setting up an SSH key for GitHub.
  • An outdated version of Git is installed
    • Cause: Ubuntu repositories prioritize stability over freshness.
    • Solution: To get a newer version, add the official Git PPA:
      sudo add-apt-repository ppa:git-core/ppa
      sudo apt update
      sudo apt install git
      
      After this, git --version will show a more recent version.
  • Error fatal: unable to access '...': Could not resolve host
    • Cause: Network connectivity or DNS issues.
    • Solution: Check internet access (ping 8.8.8.8), DNS settings, and proxy configuration (if used).

F.A.Q.

How do I update Git to the latest version on Ubuntu?
Do I need to install Git separately for each user?
What's the difference between `git` from Ubuntu's repository and from the official website?
How to check if Git installed correctly?

Hints

Update the package list
Install Git
Verify installation
Configure global settings
Check configuration
FixPedia

Free encyclopedia for fixing errors. Step-by-step guides for Windows, Linux, macOS and more.

© 2026 FixPedia. All materials are available for free.

Made with for the community