ObjectiveThe objective is to install the distributed version control system git on Ubuntu 18.04 Linux. First, we will be installing git on Ubuntu from a standard Ubuntu repository and later we will perform git installation from the source code.
Operating System and Software Versions
- Operating System: - Ubuntu 18.04 Bionic Beaver
RequirementsPrivileged access to your Ubuntu System as root or via the
sudocommand is required.
- # - requires given linux commands to be executed with root privileges either directly as a root user or by use of the
- $ - requires given linux commands to be executed as a regular non-privileged user
Install Git on Ubuntu from repositoryFirst we will be installing git on Ubuntu from its standard repository. To do so simply execute the command:
ubuntu:~$ sudo apt -y install gitOnce ready you can check for a correct git installation by retrieving git's version:
$ git --version git version 2.15.1You have now installed git on your Ubuntu system.
Install Git on Ubuntu from Source CodeInstallation of git from a standard Ubuntu repository does not yield the latest git version. In some rare cases you may wish to install the latest git version. To do so we need to install Git from the source code.
Let's start by installation of all prerequisites. Enter the command:
ubuntu:~$ sudo apt -y install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzipNext, use your browser and head over to the official git repository:
masterbranch. Next, click on
Tagsand select your desired Git version you wish to install. Due to the possible unstable nature, it is a good idea to avoid release candidate (rc) versions if possible.
From here click on
Clone or Downloadbutton. Next, right click on
Download ZIPand select
Copy link address.
Back to your terminal, use
wgetcommand to download Git zip package using the previously retrieved git link download address. Example:
ubuntu:~$ wget https://github.com/git/git/archive/v2.16.2.zipUnzip the download git package. Your git version number may be different:
ubuntu:~$ unzip v2.16.2.zipAt this stage we are ready to compile and install git. The following sets of commands will compile the previously downloaded git source code and install git binaries on your Ubuntu 18.04 linux system. Change the version number where appropriate:
ubuntu:~$ cd git-2.16.2 ubuntu:~$ make prefix=/usr/local all ubuntu:~$ sudo make prefix=/usr/local installIf all went well you should now have git installed on your Ubuntu 18.04 system. To confirmg run:
ubuntu:~$ git --version git version 2.16.2
Post-Install git ConfigurationYou can now use git to clone any repository. However if you wish to make git commits you first need to set your personal information which will be submitted to main branch with each your commit. Enter the following linux commands to set your Name and email address:
ubuntu:~$ git config --global user.name "Your Name Here" ubuntu:~$ git config --global user.email "firstname.lastname@example.org"You can always change this settings by editing the main
~/.gitconfiggit configuration file located withhin your home directory:
[user] name = Your Name Here email = email@example.com