Skip to content

How to install Git on Linux (Ubuntu)

In this post I’m going to detail how to get Git up and running on Linux, in particular on Ubuntu.

First, open your terminal. We’ll use the command line for this installation.

Step 1: Update your package list with the following command:

sudo apt update

You may need to enter your password. This is a standard security measure.

Step 2: Install Git using this command:

sudo apt install git

Ubuntu will now install Git for you.

To verify the installation, type:

git --version

This should display the installed Git version.

Next, set up your Git identity:

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

Replace “Your Name” and “youremail@example.com” with your actual details.

If you use VS Code, you can set it as your default Git editor:

git config --global core.editor "code --wait"

This will open VS Code for commit messages and other Git operations that require text input.

With Git installed, you can start version controlling your projects. Navigate to your project folder and use git init to create a new repository.

While Git may seem complex initially, it becomes an invaluable tool with practice. It’s widely used in software development for its powerful version control capabilities.

Check out my Git Cheat Sheet on freeCodeCamp, and download the PDF version from https://flaviocopes.com/access


→ Here's my latest YouTube video

→ I wrote 17 books to help you become a better developer, download them all at $0 cost by joining my newsletter

JOIN MY CODING BOOTCAMP, an amazing cohort course that will be a huge step up in your coding career - covering React, Next.js - next edition February 2025

Bootcamp 2025

Join the waiting list