While Git comes pre-installed in most Linux operating systems, there might be cases when you need to install Git manually.  

Unlike Mac and Windows, the easiest way to install Git on Linux is to use the command line. But since there are multiple versions of Linux, you need to learn multiple commands to install Git.

This guide will show how to install Git properly on different Linux versions. So, let’s get started.


Installing Git on Various Versions of Linux

Instead of being one operating system, Linux is a family of open-source operating systems based on the Linux kernel. You can install Git on a Linux distro by using the terminal.

These different versions of Linux are called distributions (or distros), and each distro has its own command for installing Git. So, let us look at them individually.

Here’s a table showing commands for Installing Git in multiple versions of Linux:

Linux DistrosCommands
Ubuntusudo apt-get updatesudo apt-get install git
Arch Linuxsudo pacman -S git
CentOSsudo yum install git
Fedorasudo dnf install git
Gentoosudo emerge –ask –verbose dev-vcs/gitsudo pacman -S git
RedHatsudo dnf install git
FreeBSDsudo pkg update -fsudo pkg install git


After you have installed Git, use the git –version command to verify the installation.


How to Configure Git on Linux?

You might want to configure a few things before you use Git for the first time. The git config command lets you do this. Here are some of the things you can configure:

Configurations Commands
View all your Git settingsgit config –list –show-origin
Set your Username and Emailgit config –global user.name “Harry Potter”
git config –global user.email harry@example.com
Change Default Branch Namegit config –global init.defaultBranch main
Change your Code Editorgit config –global core.editor “‘ full path to the executable file'”

Launch a Git Project on Linux

To launch a Git project on Linux, go to the file directory where you want to create a new GIt repository.

For example, if your project folder is in the path /home/project/new-project, you can use the CD command in the Linux terminal to go to this folder.

Just type this command: cd /home/tp/projects

You can now initialize a Git repository with the command: git init

Doing this will give you the following output:

Initialized empty Git repository in /home/project/new-project/.git/


Frequently Asked Questions


1. Can I use Git on Linux?

Yes. Git was created for Unix-based operating systems like Linux.


2. How to verify if Git is installed on Linux?

To verify a Git installation on Linux, you can use the command git –version


3. Is Git installed on Linux by default?

In most Linux systems, Git is installed by default. But there might be some cases where you need to install Git manually.