The easiest way for installing Git on your computer is visiting the page Git downloads and choosing download for Linux where the latest stable upstream Git version is provided. Also, read how to Install Git on Mac and on Windows.
First step is to open a terminal window.
sudo apt update
sudo apt-get install git
The output will be like this:
git version 2.17.0
git config --global user.name "W3docs" git config --global user.email [email protected]
[ .. ] [user] user.name=W3docs [email protected] [ .. ]
In case you wish to install the latest git version you will have to install Git from the source code.
Compiling the software from source is a more flexible method for installing Git. This method will take longer time, but it will allow you to download the latest release and will give you some control over the options.
sudo apt update
sudo apt install make libssl-dev libghc-zlib-dev libcurl4-gnutls-dev libexpat1-dev gettext unzip
unzip cd git-2.19.0
make prefix=/usr/local all sudo make prefix=/usr/local install
You will get an output like this:
git version 2.19.0
Now it’s time to set up Git and provide user information by using the git config command:
git config --global user.name "W3docs" git config --global user.email "firstname.lastname@example.org"
The result will be like this:
user.name=W3docs [email protected] ...
If you want to see all the configuration items that have been set previously, use the git config command with the --list option. And if you want to change the details you provided, change the settings by editing the main .gitconfig git configuration file located within your home directory.