Git is a command-line based software application developed for tracking changes of source codes and files and management of version control system. It is an essential tool in the modern software development field in any tech-stack. In this tutorial, we will learn How to Install Git on Ubuntu 20.04 LTS.
Ubuntu 20.04 Notes
On most of the server version of Ubuntu 20.04. The Git package should be installed by default. Especially when you launch a Ubuntu 20.04 LTS image from a cloud server then the git package should be installed by default. To check if it is already installed or not:
$ git --version
If Git is already installed then you should see something like the below:
$ git --version git version 2.25.1 $
If you don’t get back output like the above then let’s install the Git package from the apt repository
Open up Terminal, and type the below commands to install git from the apt repository (Server / Desktop):
$ sudo apt update $ sudo apt install git
After running the above commands Git should be installed successfully (Proper internet connection needed).
Now check the git version again by
$ git --version. Now you should get the current Git version back.
In general, we develop any software locally and then push it to a remote git server like GitHub or Bitbucket. We can do that using the Git CLI tool.
However, when we will push a repository from local to remote we need an identity. Generally, the name is shown on the Git profile on the remote git server. And additionally, the email address of the pusher. The configuration is required.
$ git config --global user.name "Your Name" $ git config --global user.email "email@example.com"
Now Git is configured and ready for use. To check the current configuration:
$ git config --list
Edit Git Configuration
To edit the current git user and user email you have to edit the configuration file. To to that:
$ nano ~/.gitconfig
name = Your Name
email = firstname.lastname@example.org
Edit the file to change the name and email then save and exit the file.