• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Install Git on Ubuntu 18.04

Written by Admin, Updated On June 8, 2019
git, ubuntu
How to Install Git on Ubuntu 18.04

Git is the most popular distributed version control system. It used to track changes in source code during software development. It allows to collaborate with programmers, revert to previous changes and create branches. In this tutorial, you will learn how to install Git on Ubuntu system.

Prerequisites#

You must have logged in with non-root user account with sudo privileges.

Install Git on Ubuntu#

Git is available at Ubuntu default apt repository so we will install from there. It’s always recommended to install packages from Ubuntu default repository.

So first of all we need to update apt package manager index using below command:

sudo apt update

Once the list is updated execute the below command to install Git:

sudo apt install git

You can verify the installation by typing:

git --version

It will show output like below:

Output
git version 2.11.0

That’s all. You have successfully installed Git version on you Ubuntu system.

Installing Git from a Source#

Another installation method is to compile the software from source. It will allow you to download the latest release and to do customization. But you can’t manage Git package from apt package manager.

Before you start, you need to install necessary software which Git required. These all are available from default Ubuntu repository. Execute below commands:

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

After that, you can go ahead and get the version of Git you want by visiting the Git project’s mirror on GitHub and copy the latest release link address that ends in .zip

https://github.com/git/git/releases

Now we will download Git source to /tmp directory on your Ubuntu system. Move to /tmp directory by typing:

cd /tmp

Use the wget command to download the archive file as git.zip:

sudo wget https://github.com/git/git/archive/v2.21.0.zip -O git.zip

Once download is finished, unzip the downloaded file and move to the git source directory by typing:

unzip git.zip
cd git-*

Now, you can compile and install Git by typing these two commands:

sudo make prefix=/usr/local all
sudo make prefix=/usr/local install

Again, you can verify installation by typing:

git --version

It should show installed version of Git as given below:

Output
git version 2.21.0

Later, if you have need to upgrade to a newer version, you can repeat the installation process.

Setting Up Git#

Now your Git is installed and you need to configure it by setting up email address and username:

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

You can see entered details by typing:

git config --list
Output
user.name=Your Name
user.email=youremail@yourdomain.com

These settings are stored at ~/.gitconfig file and you can see content as below:

[user]
   name = Your Name
   email = yourname@yourdomain.com

You can make other git configuration changes by using git config command or you can edit the ~/.gitconfig file manually.

Conclusion#

Finally, you have learned how to install Git on your Ubuntu server and how to Setting up Git. You can learn more about Git at Pro Git Book.

If you face any problem at installation time, leave a comment below.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Install Tomcat 9 on CentOS 7
Next Article   How to Install Go on Debian 9

Related Posts

  • How to Install Apache, MySQL, PHP (LAMP) on Ubuntu 22.04

    How to Install LAMP on Ubuntu 22.04

    March 20, 2023
  • How to Install LEMP Stack on Ubuntu 22.04

    How to Install LEMP Stack on Ubuntu 22.04

    March 18, 2023
  • How to Install Memcached on Ubuntu 22.04

    How to Install Memcached on Ubuntu 22.04

    March 16, 2023

Leave a Reply Cancel reply

DigitalOcean Referral Badge

Popular Posts

  • How to Install Microsoft Edge Browser on Ubuntu 22.04
    How to Install Microsoft Edge Browser on Ubuntu 22.04 March 14, 2023
  • How to Install Ruby on Ubuntu 22.04 LTS
    How to Install Ruby on Ubuntu 22.04 LTS February 27, 2023
  • How to Install PHP 8.2 on Debian 11
    How to Install PHP 8.2 on Debian 11 Linux February 24, 2023
  • How to Install LEMP Stack on Ubuntu 22.04
    How to Install LEMP Stack on Ubuntu 22.04 March 18, 2023
  • How to Install Set Up Apache Virtual Hosts on Ubuntu 22.04
    How to Set Up Apache Virtual Hosts on Ubuntu 22.04 March 2, 2023
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook