How to Install Git on Ubuntu Linux

|

|

This tutorial provides instructions on how to install Git, a popular open-source version control system, on Ubuntu 20.04 | 18.04. Users can either install Git from Ubuntu repositories using simple apt commands, or from the source for getting the latest version. The process includes downloading the latest release and compiling it on the system. Both…

This brief tutorial shows students and new users how to install Git on Ubuntu 20.04 | 18.04.

Git is probably the most popular open-source, distributed version control system today. Git allows developers to keep track of projects, code changes, create and revert changes, and collaborate with other developers.

Created by Linux Torvalds, the creator of the Linux operating system, Git is now owned by Microsoft.

If you’re a student or new user looking for an easy tutorial on installing Git on Ubuntu, the steps below should be handy.

To get started with installing Git on Ubuntu, follow the steps below:

Install Git from the Repository

Git packages come ready to install from Ubuntu default repositories. You can simply run the apt-get command to install it in Ubuntu. However, the versions available in Ubuntu repositories may not be the latest.

The installation is pretty straightforward. Simply run the commands below to install Git on Ubuntu.

sudo apt update
sudo apt install git

That should download and install Git packages.

To verify that Git is installed and functioning, run the commands below

git --version

The command above will output the line below:

Output:
git version 2.25.1

You have successfully installed Git on Ubuntu.

Install Git from Source

Again, as we mentioned above, the version that comes with Ubuntu might not necessarily be the latest. To install the latest, you will want to install the build and install it from the source.

To do that, use the steps below.

First, install the required and recommended packages to build Git. Run the commands below to do that.

sudo apt update
sudo apt install dh-autoreconf libcurl4-gnutls-dev libexpat1-dev make gettext libz-dev libssl-dev libghc-zlib-dev

Next, go to the Git project page to check the latest releases. Get the release version and replace the one below if it’s newer.

wget -c https://github.com/git/git/archive/v2.32.0.tar.gz -O - | sudo tar -xz -C /usr/src

Once the download is complete, change into the source directory and run the commands below to compile and build Git.

cd /usr/src/git-*
sudo make prefix=/usr/local all
sudo make prefix=/usr/local install

Depending on the speed of your machine, compiling should take a couple of minutes. Once done, you can verify the Git version by running the command below again.

git --version
Output:
git version 2.32.0

That should do it!

Conclusion:

This post showed you how to install Git on Ubuntu 20.04 | 18.04. If you find any error above, please use the comment form below to report.

Like this:



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.