Linux

Installing Git on Linux: A Step-by-Step Guide for Beginners

This guide will help you quickly install the Git version control system on any Linux distribution. You'll learn how to install the package via package manager, verify the installation, and perform initial setup for working with GitHub and other services.

Updated at February 17, 2026
5-15 min
Easy
FixPedia Team
Применимо к:Ubuntu 22.04+Debian 11+Fedora 36+RHEL 8+Arch LinuxopenSUSE Leap 15.3+

Introduction / Why This Is Needed

Git is the de facto standard for version control in modern development. It's essential for effectively collaborating on code within a team, participating in open-source projects on GitHub/GitLab, or even tracking changes in personal projects. Installing Git on Linux is typically the first task for any developer, DevOps engineer, or system administrator. This guide covers all popular distributions and provides working commands.

Prerequisites / Preparation

Before you begin, ensure that:

  1. You have access to a terminal (Ctrl+Alt+T or via the applications menu).
  2. You have superuser (sudo) privileges to install packages.
  3. You have an internet connection to download packages from official repositories.
  4. Important: The instructions use commands for modern distribution versions (Ubuntu 22.04+, Fedora 36+, RHEL 8+). For very old systems, package names or commands may differ.

Step-by-Step Guide

Step 1: Install Git

Choose the command corresponding to your distribution.

For Debian/Ubuntu-based distributions (Ubuntu, Linux Mint, Pop!_OS)

sudo apt update
sudo apt install git -y
  • apt update — updates the list of available packages.
  • apt install git — installs the git package.
  • The -y flag automatically confirms the installation.

For RHEL/Fedora-based distributions (Fedora, RHEL, CentOS Stream, AlmaLinux, Rocky Linux)

sudo dnf install git -y

For older versions of CentOS 7/RHEL 7, use yum instead of dnf:

sudo yum install git -y

For Arch Linux and derivatives (Manjaro, EndeavourOS)

sudo pacman -S git --noconfirm
  • -S — the installation syntax for pacman.
  • --noconfirm — skips confirmation prompts.

For openSUSE (Leap, Tumbleweed)

sudo zypper install git

Step 2: Verify the Installation

After the installation completes, verify that the git command is available and functional:

git --version

Expected output (example):

git version 2.43.0

If the command is not found, restart your terminal or run hash -r (in Bash) to refresh the command cache.

Step 3: Initial Configuration (Mandatory!)

Git requires you to specify your name and email. This data will be publicly visible in your commits on GitHub/GitLab.

git config --global user.name "Your Full Name"
git config --global user.email "your.email@example.com"
  • --global — sets the configuration for all repositories for the current user.
  • Replace "Your Full Name" and "your.email@example.com" with your actual details.

Verify your configuration:

git config --list

You should see lines containing user.name and user.email.

Verification of Results

  1. Installation successful: The git --version command shows version 2.30 or higher.
  2. Configuration complete: The git config user.name command returns your name, and git config user.email returns your email.
  3. Test commit: Create a test repository to ensure everything works:
    mkdir ~/test-git && cd ~/test-git
    git init
    echo "# Test Project" > README.md
    git add README.md
    git commit -m "First commit"
    
    If the git commit command executes without errors (except for a warning about an empty email if you didn't set one), Git is fully ready for use.

Potential Issues

Error: git: command not found

  • Cause: Git is not installed or its path is not included in the PATH variable.
  • Solution: Reinstall Git by following the steps above. If the problem persists, locate the path to the executable (which git or whereis git) and add it to PATH in your ~/.bashrc or ~/.zshrc file.

Permission error during installation (Permission denied)

  • Cause: Attempting to install without superuser privileges.
  • Solution: All installation commands must start with sudo. Ensure your user is in the sudo group (groups $USER).

Error: fatal: unable to access '...': Could not resolve host: github.com

  • Cause: Network connectivity or DNS issues.
  • Solution: Check your internet connection. Try pinging GitHub: ping github.com. If the ping fails, check your DNS settings or firewall.

Issue: git --version shows an old version after installation

  • Cause: In the official repositories of some distributions (especially LTS versions), the Git version may not be the latest.
  • Solution: To get the latest version, you will need to add a third-party repository (PPA for Ubuntu) or build Git from source. For most tasks, the version from the official repository is sufficient.
# Example for Ubuntu (adds the official Git PPA)
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
# Example for Fedora (uses the Copr repository)
sudo dnf copr enable @git/core
sudo dnf install git
# Building from source (a universal but complex method)
# 1. Install dependencies: build-essential, libssl-dev, libcurl4-gnutls-dev, etc.
# 2. Download the source from kernel.org
# 3. ./configure && make && sudo make install

F.A.Q.

What is the difference between Git and GitHub?
Do I need to configure Git after installation?
How to completely remove Git from the system?
Why is the `git` command not found after installation?

Hints

Identify your distribution and package manager
Install Git via package manager
Check the installed Git version
Configure global Git settings

Did this article help you solve the problem?

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