A Step-by-Step Guide to Install Git on Ubuntu and Linux Mint

Git logo

This tutorial will be helpful for beginners to install Git on Ubuntu 22.04 LTS, Ubuntu 20.04 LTS, Alma Linux 9, Fedora, and Linux Mint 21.

What is GIT

Git, the popular distributed version control system, is an essential tool for developers and anyone working with code.

As you are all aware Ubuntu and Linux Mint typically come with Git pre-installed, you might want to install a specific version like 2.43.1 for compatibility or feature reasons.

This guide will walk you through the process step-by-step.

Prerequisites

Before proceeding to install the latest version of git, below requirements needs to be achieved

  • An Ubuntu or Linux Mint system.
  • SUDO access to a terminal window.
  • A basic understanding of command-line navigation.

Understanding the Installation Methods

Via Source code :

This provides tar file versions directly from the git repo it is time-consuming and it can be done via CLI.

Personal Package Archive (PPA):

This offers newer versions but might introduce compatibility issues. Choose this only if you specifically need Git 2.43.1 or a similar newer version.

How to Install Git on Ubuntu and Linux Mint

Method 1: Personal Package Archive (PPA): (Recommended for Most Users)

Before proceeding make sure the system is up to date

sudo apt update && sudo apt upgrade -y

Add the PPA

sudo add-apt-repository ppa:git-core/ppa

Update the system

sudo apt update

Install git

sudo apt install git 

Method 2: Using the Source file (applicable for all Linux distributions)

Install the required dependencies before proceeding

For Ubuntu / Linux Mint

sudo apt update
sudo apt install build-essential libssl-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

Red Hat /CentOS / Fedora

sudo dnf groupinstall "Development Tools"
sudo dnf install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-CPAN perl-devel

Arch Linux

sudo pacman -Syu --needed base-devel libcurl-compat libexpat

Download the Git 2.43.1 tar file from the downloads page or use the below command

wget https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.43.1.tar.gz

Extract the tar file and configure the GIT

tar -xf git-2.43.1.tar.gz -C /opt
cd /opt/git-2.43.1 && make prefix=/usr/local all install

Verify the git version

git --version

Install git on ubuntu

Setting up GIT

Configure Username and Email

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

Replace “Your Name” and “[email protected]” with your details.

Verify Configuration

git config --list

This will display your Git configuration, including username and email.

READ  How to Install LazyGit on Ubuntu

References:

Official Git documentation – https://git-scm.com/docs

Atlassian Git tutorial – https://www.atlassian.com/git/tutorials/install-git

Conclusion

You’ve successfully installed and configured Git on your Ubuntu or Linux Mint machine.

Do let us know your comments and feedback in the comments section below.

If my articles on TipsonUNIX have helped you, kindly consider buying me a coffee as a token of appreciation.

Buymeacoffee

Thank You for your support!!

Leave a Comment