How To

Install Git on Ubuntu 18.04: Setup and Configuration Guide

Git is the de-facto standard for version control in software development. It tracks every change to your code, lets you revert to earlier states, create branches for new features, and collaborate with your team without overwriting each other’s work. Teams use Git to work on the same codebase in parallel and keep a complete history of every change ever made to a project.

Git was originally created by Linus Torvalds — the same person who wrote the first version of the Linux kernel.

This guide shows you how to install Git on Ubuntu 18.04 using the apt package manager or by compiling from source, and how to configure your user identity before making your first commit. The same steps apply to Ubuntu 16.04 and other Ubuntu-based distributions.

<strong>Prerequisite:</strong>&nbsp;You need sudo access.

Install Git on Ubuntu Using apt

The quickest and recommended way to install Git is from Ubuntu’s default repositories. The version available may not be the absolute latest, but it is stable, well-tested, and maintained automatically by apt.

Update the package index:

bashsudo apt update

Install Git:

bashsudo apt install git

Verify the installation:

bashgit --version

Output:

git version 2.17.1

Git 2.17.1 is the version included in the Ubuntu 18.04 repositories. If this version meets your needs, skip ahead to the Configuration section below.

Install Git from Source

If you need a newer Git release than what Ubuntu’s repositories offer, you can compile it directly from source. The trade-off is that apt cannot manage this installation, you have to repeat the build process each time a new version is released.

Install the required build dependencies:

bashsudo apt updatesudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip

Visit the Git releases page on GitHub to find the latest stable version. At the time of writing, that is 2.23.0. Update the version number in the commands below if a newer release is available.

Download the source archive:

bashsudo wget https://github.com/git/git/archive/v2.23.0.tar.gz -O git.tar.gz

Extract the archive and move into the source directory:

bashsudo tar -xf git.tar.gzcd git-*

Compile and install Git:

bashsudo make prefix=/usr/local allsudo make prefix=/usr/local install

Confirm the installed version:

bashgit --version

Output:

git version 2.23.0

Configure Git for First Use

Before you start making commits, Git needs to know who you are. It attaches your name and email address to every commit you create. Set your global identity with these two commands:

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

The --global flag applies these settings to all repositories on your system. If you need different credentials for a specific project, run the same commands from inside that project’s directory and leave out --global.

Verify your configuration is saved:

bashgit config --list

Output:

user.name=Your Nameuser.email=youremail@yourdomain.com

Git stores these settings in the ~/.gitconfig file in your home directory. You can open and edit it directly if you need to make any further adjustments.

Git is now installed and configured on your Ubuntu 18.04 system. You are ready to initialize repositories, clone projects, create branches, and start collaborating with your team. Leave a comment below if you run into any issues during the setup.

Cyber Defence

Recent Posts

Install phpMyAdmin on Ubuntu 18.04 with Apache: Setup Guide

phpMyAdmin is a free, open-source PHP application that provides a browser-based interface for managing MySQL and…

9 hours ago

Install Zabbix on Ubuntu 18.04: Server Setup with MySQL Backend

Zabbix is a mature open-source infrastructure monitoring platform that collects metrics from network devices, servers, virtual…

10 hours ago

Install Gradle on Ubuntu 18.04: Set Up OpenJDK and Environment

Gradle is a powerful open-source build automation tool used primarily for Java, Kotlin, Groovy, and Android…

10 hours ago

Install TeamViewer on Ubuntu 18.04: Download the .deb and Set Up

TeamViewer is a proprietary cross-platform remote access application for remote control, desktop sharing, file transfer, and online meetings. It is one of the most widely used remote support tools in the world, available for Windows, macOS, Linux, iOS, and Android. TeamViewer is not included in the Ubuntu repositories because it is proprietary software. This guide covers how to install TeamViewer on Ubuntu 18.04 using the official .deb package. The same steps apply to Ubuntu 16.04, Debian, Linux Mint, and Elementary OS. <strong>Prerequisite:</strong>&nbsp;You&nbsp;need&nbsp;sudo&nbsp;access. Install TeamViewer on Ubuntu: Download the .deb Package Download the official TeamViewer .deb package. The _amd64.deb suffix indicates this package is for 64-bit x86-64 systems. For ARM-based machines, download the appropriate package from the TeamViewer Linux downloads page: bashwget https://download.teamviewer.com/download/linux/teamviewer_amd64.deb Install the package using apt. The ./ prefix tells apt this is a local file path, not a package name from the repositories:…

10 hours ago

Install Nagios Core on Ubuntu 18.04: Build from Source Guide

Nagios is one of the most widely used open-source infrastructure monitoring systems in the world. It…

10 hours ago

Install Laravel on Ubuntu 18.04 with Composer: Setup Guide

Laravel is an open-source PHP web application framework built around an expressive, developer-friendly syntax. It is…

1 day ago