Steps to Install Git on Ubuntu 20

In this tutorial, we’ll explain steps to install Git on Ubuntu 20. Git is the popular distributed version control system (VCS) used for source code management (SCM).

Steps to Install Git on Ubuntu 20

Steps to Install Git on Ubuntu 20

Prerequisite:

  • You Need Ubuntu 20 Server.
  • You need SSH access to Ubuntu 20 Server.
  • Required sudo / root user permission.

Step 1: Update Ubuntu package

$ sudo apt-get update

Step 2: Install git on ubuntu 20

$ sudo apt-get install git-core -y

you can also manually download git package from official download page.

Demo Output

root@Ubuntu-20:~# sudo apt-get install git-core -y

Reading package lists... Done

Building dependency tree       

Reading state information... Done

Note, selecting 'git' instead of 'git-core'

The following additional packages will be installed:

  git-man liberror-perl

Suggested packages:

  git-daemon-run | git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-cvs git-mediawiki git-svn

The following NEW packages will be installed:

  git git-man liberror-perl

0 upgraded, 3 newly installed, 0 to remove and 32 not upgraded.

Need to get 5,464 kB of archives.

After this operation, 38.4 MB of additional disk space will be used.

Get:1 http://us.archive.ubuntu.com/ubuntu focal/main amd64 liberror-perl all 0.17029-1 [26.5 kB]

Get:2 http://us.archive.ubuntu.com/ubuntu focal/main amd64 git-man all 1:2.25.1-1ubuntu3 [884 kB]

Get:3 http://us.archive.ubuntu.com/ubuntu focal/main amd64 git amd64 1:2.25.1-1ubuntu3 [4,554 kB]                                                                                                         

Fetched 5,464 kB in 1min 27s (63.0 kB/s)                                                                                                                                                                  

Selecting previously unselected package liberror-perl.

(Reading database ... 142493 files and directories currently installed.)

Preparing to unpack .../liberror-perl_0.17029-1_all.deb ...

Unpacking liberror-perl (0.17029-1) ...

Selecting previously unselected package git-man.

Preparing to unpack .../git-man_1%3a2.25.1-1ubuntu3_all.deb ...

Unpacking git-man (1:2.25.1-1ubuntu3) ...

Selecting previously unselected package git.

Preparing to unpack .../git_1%3a2.25.1-1ubuntu3_amd64.deb ...

Unpacking git (1:2.25.1-1ubuntu3) ...

Setting up liberror-perl (0.17029-1) ...

Setting up git-man (1:2.25.1-1ubuntu3) ...

Setting up git (1:2.25.1-1ubuntu3) ...

Processing triggers for man-db (2.9.1-1) ...

root@Ubuntu-20:~#

Step 3: Verify Git installation

$ git --version

Demo Output:

root@Ubuntu-20:~# git --version

git version 2.25.1

root@Ubuntu-20:~#

Step 4: Configure Git in Ubuntu 20

$ git config --global user.name "your-user-name"

$ git config --global user.email "your-email-id"

Git configs work on a user basis. Assume your Linux user “tom1” will be working with git then he (tom1) must run all the commands from his user account.

For example, if you have a ‘david’ Linux user and they will be working with git then David should run the same commands from his user account, from this commits made by the “tom1” Linux user will be done with his git.

Command to see all of the Git configurations:

$ git config --list

Sample Output:

...

Output

user.name=your-user-name

user.email=your-email-id

...

All the above configurations are stored in the Git configuration file, you can also edit with text editor.

$ nano ~/.gitconfig

Sample output

~/.gitconfig contents

[user]

  name = your-user-name

  email = your-email-id

End of the tutorial, we explained the steps to install git on Ubuntu 20. Comment us below if you have any quires.

Thanks for reading this article, you’ll also like:

Steps to install Jenkins (CI/CD)

DevOps Blogs