Skip to content

How to Install Git on Linux (Ubuntu, CentOS, Amazon Linux)

โ† Back to Git


Overview

Git is a distributed version control system used to track code changes and collaborate efficiently in software projects.

In this guide, youโ€™ll learn: - How to install Git on major Linux distributions - Which package manager to use for each OS - How to verify your Git installation - Common questions beginners face after installation

This guide is suitable for beginners and DevOps engineers setting up Git for the first time.


๐Ÿง Install Git on Linux

Below are the official and recommended ways to install Git on popular Linux distributions.


๐ŸŸ  Ubuntu / Debian

Update the package index and install Git using apt:

sudo apt update
sudo apt install git -y

๐Ÿ”ต CentOS / RHEL

For CentOS 7 / RHEL 7:

sudo yum install git -y

For RHEL 8 / RHEL 9:

sudo dnf install git -y

๐ŸŸข Amazon Linux

For Amazon Linux 2:

sudo yum install git -y

For Amazon Linux 2023:

sudo dnf install git -y

โœ… Verify Git Installation

After installation, verify that Git is installed correctly:

git --version

Expected output:

git version 2.x.x


โ“ Frequently Asked Questions (FAQ)

Which Git version should I install?

Use the version provided by your OS package manager unless you specifically need a newer release.

How do I update Git on Linux?

Use the same package manager: - Ubuntu/Debian: sudo apt upgrade git - RHEL/CentOS/Amazon Linux: sudo yum update git or dnf update git

Where is Git installed on Linux?

Git is usually installed under /usr/bin/git.


๐ŸŽฅ Watch on YouTube

Git part-1


๐Ÿง  Quick Quiz โ€” Install Git

#

Which command is used to install Git on Ubuntu?


๐Ÿ“ Want More Practice?

๐Ÿ‘‰ Test your knowledge โ€“ Take the Git Basics Quiz


๐Ÿ“ฌ DevopsPilot Weekly โ€” Learn DevOps, Cloud & Gen AI the simple way.
๐Ÿ‘‰ Subscribe here