How to install Git on Ubuntu
Git is by far the most widely used distributed version control system while being free and open source. git client is not installed by default in the desktop variants of Ubuntu though despite the popularity.
git is available in Ubuntu's default apt repository, so it could easily be installed from the terminal using apt.
Steps to install Git client on Ubuntu and Debian:
-
Open terminal from the application launcher or via the <ctrl> + <alt> + <t> keyboard shortcut.
-
Update apt's package list from the repository.
$ sudo apt update [sudo] password for user: Get:1 http://security.ubuntu.com/ubuntu disco-security InRelease [97.5 kB] Hit:2 http://my.archive.ubuntu.com/ubuntu disco InRelease Get:3 http://my.archive.ubuntu.com/ubuntu disco-updates InRelease [97.5 kB] Get:4 http://my.archive.ubuntu.com/ubuntu disco-backports InRelease [88.8 kB] Fetched 284 kB in 1s (198 kB/s) Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date.
-
Install git package via apt.
$ sudo apt install --assume-yes git [sudo] password for user: Reading package lists... Done Building dependency tree Reading state information... Done 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 0 not upgraded. ##### snipped
-
Test by running git from the command line.
$ git usage: git [--version] [--help] [-C <path>] [-c <name>=<value>] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>] These are common Git commands used in various situations: start a working area (see also: git help tutorial) clone Clone a repository into a new directory init Create an empty Git repository or reinitialize an existing one ------ snipped ------
-
Install GUI-based git client (optional).