How To Install Git on Ubuntu in just 15 minutes

There are several ways to install Git on Ubuntu. The easiest is probably to install through cutting-edge codes.

Updated: 21 Jul, 23 by Susith Nonis 9 Min

List of content you will read in this article:

Git is one of the most popular decentralized version control software, with 12,000,000 users worldwide. It is free software created by Linus Torvalds, author of the Linux kernel. Git is completely free, and to know what is ubuntu you should know it well too.

Git was originally developed by Linus Torvalds. It is a fast, scalable, and distributed version control system. Its purpose is to track changes in computer files and coordinate the work that multiple people do on shared files. It is an open-source project covered by the GNU General Public License version 2. Some parts are under different licenses, compatible with GPLv2. 

1. Debian/Ubuntu (apt-get)

Git packages are available through apt:

  1. In your shell prompt, install Git ubuntu via apt-get:

$ sudo apt-get update

$ sudo apt-get install git

  1. To verify successful git installation, type git --version:

$ git –version

git version 2.9.2

  1. Configure your Git username and email address using the following commands, replacing Emma's name with your own. This information will be associated with all the commits you create:

$ git config --global user.name "Emma Paris"

$ git config --global user.email "eparis@atlassian.com"

2. Fedora (dnf/yum)

Ubuntu Git packages are available through yum and dnf:

  1. In your shell prompt, install Git using dnf (or yum, on older versions of Fedora):

$ sudo dnf install git

Or

$ sudo yum install git

  1. To verify successful installation, type git --version:

$ git --version

git version 2.9.2

  1. Configure your Git username and email address using the following commands, replacing Emma's name with your own. This information will be associated with any commits you create.

$ git config --global user.name "Emma Paris"

$ git config --global user.email "eparis@atlassian.com"

1. Debian/Ubuntu

Git requires several dependencies to build on Linux. These are available through apt:

  1. In your shell prompt, install the necessary dependencies via apt-get:

$ sudo apt-get update

$ sudo apt-get install libcurl4-gnutls-dev libexpat1-dev gettext libz-dev libssl-dev asciidoc xmlto docbook2x

  1. Clone ubuntu Git source (or if a version of Git is not yet installed, download and extract it):

 $ git clone https://git.kernel.org/pub/scm/git/git.git

  1. To develop Git and install it under /usr, run make:

$ make all doc info prefix=/usr

$ sudo make install install-doc install-html install-info install-man prefix=/usr

2. Fedora

Git requires several dependencies to build on Linux. These are available via yum and dnf:

  1. In your shell prompt, install the necessary build dependencies using dnf (or yum, on older versions of Fedora):

$ sudo dnf install curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel asciidoc xmlto docbook2X

For yum, you may need to install the Extra Packages for Enterprise Linux (EPEL) repository first:

$ sudo yum install epel-release

$ sudo yum install curl-devel expat-devel gettext-devel openssl-devel perl-devel zlib-devel asciidoc xmlto docbook2X

  1. Create a docbook2X symbolic link (symlink) to the filename that the Git build expects:

$ sudo ln -s /usr/bin/db2x_docbook2texi /usr/bin/docbook2x-texi

  1. Clone the Git source (or if a version of Git is not yet installed, download and extract it):

$ git clone https://git.kernel.org/pub/scm/git/git.git

  1. To develop Git and install it under /usr, run make:

$ make all doc prefix=/usr

$ sudo make install install-doc install-html install-man prefix=/usr

The easiest way to ubuntu install Git is by visiting the Git downloads page and choosing download for Linux, where the latest stable upstream version of Git is provided.

It will be better than before starting the process; you are informed about the conventions used when Git is installed.

# - request that the given linux command be run with root privileges, either directly as root or via the sudo command

$ - requests that the given linux command be run as a regular, not privileged user

1. Install Git ubutnu from Repository

First, we must open a terminal window. Copy & paste the following in the terminal window and press Enter. You may be asked to enter your password. With a full update, you can download and install the Git:

#aptupdate

# apt-get install git

InstallGit

To confirm that you installed Git correctly, run the following command:

# git --version

The output will be like this:

git version 2.17.0

Now set your personal information. Enter the following commands to add your name and email:

# git config --global user.name "W3docs"

# git config --global user.email info@.w3docs.com

As you configure the reference in Git, you can open a Git configuration file where you will find the details like this:

[ .. ]

[user]

        user.name=W3docs

        user.email=info@w3docs.com

[ .. ]

Note that the version you install via these repositories may be older than the latest version. If you need the latest output, consider the following method.

2. Install Git from Source

If you want to install the latest version of Git, you must install Git from the source code.

Compiling source software is a more flexible method than installing Git. This method is more time-consuming, but it allows you to download the latest release and gives you some control over the options.

Before starting, we must install the software on which Git depends. So you can update your local package index and then install the packages.

$ sudo apt update

$ sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

Then choose the version of Git you want by visiting Git Source Code Mirror.

Choose the "master" branch, click on the "Tags" list and select your preferred version of Git.

🚀 Elevate your online game with a high-performance Linux VPS! 🌐💻 Unleash the potential of virtual servers to take your website and apps to new heights! 📈💪

To install Git on Ubuntu, the easiest way is to use the apt-get command.

To get the latest LTS version, you need to add a repository:

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

The result is displayed like this:

How To Install Git on Ubuntu in just 15 minutes

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

PPA publishes dbgsym; you may need to include 'main/debug' component.

Repository: 'deb https://ppa.launchpadcontent.net/git-core/ppa/ubuntu/jammy main'

Description:

The most current stable version of Git for Ubuntu.

For release candidates, go to https://launchpad.net/~git-core/+archive/candidate.

More info: https://launchpad.net/~git-core/+archive/ubuntu/ppa

Adding repository.

Press [ENTER] to continue or Ctrl-c to cancel.

Found existing deb entry in /etc/apt/sources.list.d/git-core-ubuntu-ppa-jammy.list

Adding deb entry to /etc/apt/sources.list.d/git-core-ubuntu-ppa-jammy.list

Found existing deb-src entry in /etc/apt/sources.list.d/git-core-ubuntu-ppa-jammy.list

Adding disabled deb-src entry to /etc/apt/sources.list.d/git-core-ubuntu-ppa-jammy.list

Adding key to /etc/apt/trusted.gpg.d/git-core-ubuntu-ppa.gpg with fingerprint E1DD270288B4E6030699E45FA1715D88E1DF1F24

Hit:1 http://nova.clouds.archive.ubuntu.com/ubuntu jammy InRelease

Hit:2 http://nova.clouds.archive.ubuntu.com/ubuntu jammy-updates InRelease

Get:3 http://nova.clouds.archive.ubuntu.com/ubuntu jammy-backports InRelease [99.8 kB]

Ign:4 https://pkg.jenkins.io/debian-stable binary/InRelease

Hit:5 https://pkg.jenkins.io/debian-stable binary/Release

Hit:6 https://ppa.launchpadcontent.net/git-core/ppa/ubuntu jammy InRelease

Hit:7 http://security.ubuntu.com/ubuntu jammy-security InRelease

Fetched 99.8 kB in 1s (112 kB/s)

Reading package lists... Done

How To Install Git on Ubuntu in just 15 minutes

Basic setup

After installation, one of the first things to do is set up our username and email address. Git associates your identity with every commit you make. To configure them with the global confirmation name and our email address, you need to run the following commands:

git config --global user.name "Nuestro number"

git config --global user.email "tudireccion@dominio.com"

Once executed, we can verify the typing configuration changes:

git config –list

These configuration settings are stored in the ~/.gitconfig file. If you want to make more changes to the Git configuration, it is recommended to do so using Git config, although we can also do this by editing the ~/.gitconfig file by hand.

 To get more information about this version control system and how to use it, users can access the documentation or help found on GitHub. If you want to know how to check the Ubuntu version, there are some measures through the link. Overall as a final word, Ubuntu hosting would be essential throughout the process. 

People also read: 

Susith Nonis

Susith Nonis

I'm fascinated by the IT world and how the 1's and 0's work. While I venture into the world of Technology, I try to share what I know in the simplest way with you. Not a fan of coffee, a travel addict, and a self-accredited 'master chef'.