Enter your email address below and subscribe to our newsletter

How to Install Git in Ubuntu

Want to install the latest version of Git on Ubuntu? Here's how to do it in 2 simple steps.

Share your love

For every software developer, Git is one of the most important parts of their software development cycle. But the question is how do you install Git on Ubuntu?

If you are ok using a little older (but stable) version of Git, then it can be installed in a single command as shown here:

sudo apt install git

Want more details? Well, in this tutorial, I will walk you through two ways you can install Git in Ubuntu:

  1. Using the default repository (easy)
  2. Using Git PPA (for the latest version of Git)

At the end of this tutorial, I will also walk you through some basics of setting up Git on Ubuntu.

Install Git using the default repository (easy)

This is the easiest way one can set up Git on Ubuntu as you are using the default repository of Ubuntu. The best part of this method is all it takes is one command to install Git on Ubuntu.

To install Git using the default repository, use the following command:

sudo apt update && sudo apt install git

Once you are done with the installation, you can check the installed version of Git using the following command:

git --version
Install Git using the default repository of Ubuntu

While writing, this method gave me Git version 2.43 on Ubuntu 24.04 LTS.

Install the latest version of Git on Ubuntu

If you want to use the latest version of Git, there are two ways to do it. You can either build Git from the source which is quite complex or you use PPA to get the latest version by executing two or three commands.

So in this section, I will walk you through how you can use Git PPA to install the latest version of Git on Ubuntu.

To use Git PPA, first, execute the following command to add Git PPA to your Ubuntu machine:

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

To take effect from the added repository, update the repository index using the given command:

sudo apt update

Finally, install the latest version of Git on Ubuntu using the following command:

sudo apt install git

Now, you can check the installed version of Git, which should be the most recent release of Git:

git --version
Install the latest version of Git on Ubuntu using PPA

While writing, Git 2.46 was the most recent version and this method gave me the same version.

Setting up Git on Ubuntu

After installing Git, I recommend everyone should do basic configuration so that whenever you make commit changes, it will have your contact information.

If you won’t perform these steps and try to make a commit directly, it will give you a message saying ‘Please tell me who you are’ like this:

kabir@GG:~$ git commit -m "update readme"
Author identity unknown

*** Please tell me who you are.

Run

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

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'kabir@GG.(none)')

To set up Git with basic information, you can use the git config command in the following manner to set up global Git configuration:

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

You can check the configuration using the following command:

git config --list

The output should look like this which will also include the configured email address and name:

kabir@GG:~$ git config --list
[email protected]
user.name=Kabir
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true

In future, if you want to change this configuration, it can easily be done by modifying the gitconfig file:

nano ~/.gitconfig
Change configuration of git

Once you are done making changes, you can save changes and exit from the nano editor.

Conclusion

It was a quick tutorial on how one can install Git on Ubuntu using two methods. I have also mentioned a simple way by which users can install the latest version of Git without much work and at the end, I have mentioned how you can setup Git on Ubuntu.

I hope you will find this tutorial helpful.

Share your love
Kabir
Kabir

A tech journalist whose life revolves around networks.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!