Git is the most popular version control, and source code management system used initially for kernel development. It was developed by Finnish-American software engineer, Linus Torvals in 2005. It offers nonlinear and distributed development support to multiple contributors working on a project.
Version control is indispensable in modern software development because these systems keep track of software at the source level. With this feature, a software development team can track changes, revert to previous stages, and create alternative files and directories. Git is helpful for many open-source projects, and it uses a cloud-based Git repository to maintain the files.
This guide will tell you how to install the latest Git version on Linux, Mac, and Windows by using their package managers. One other way to install Git is to compile from source code or XCode (or its Command Line Tools) on any operating system.
Here we discuss the installation process of Git for all the operating systems.
- Installing Git on Linux
The Git installation on Linux OS depends on the distribution used. This section you will learn how to install Git on Ubuntu, CentOS, Fedora, and Arch Linux.
But before that, we need to ensure if Git is already installed in your system.
Check if Git is installed on Linux.
You can check if Git is already installed in your system using the command ‘git – – version’ as Git is already installed in some distributions of Linux.
- If the output after the command shows the Git version, the Git is already installed; else, the terminal displays an error.
- If Git is not installed, here are the steps to install it in all the distributions.
i. Installing Git on Ubuntu
Update your local package index using the right package management tools and then download and install the Git program:
$ sudo apt update
$ sudo apt install git
ii. Installing Git on CentOS
CentOS’ native package manager ‘yum’ is used to search and install the latest Git package in the CentOS repository.
‘yum’ is updated using this command:
$ sudo yum -y update
The -y flag alerts that the system is making changes, and we can go ahead and install Git:
$ sudo yum install git
iii. Installing Git on Fedora
Both ‘yum’ and ‘dnf’ are the available Git packages for Fedora. Now, dnf is the default Fedora package manager.
$ sudo dnf update
$ sudo dnf install git
You can use the ‘yum’ command for the older Fedora version:
$ sudo yum update
$ sudo yum install git
iv. Installing Git on Arch Linux
Run the following command to install Git on Arch Linux using “pacman”.
$ sudo pacman –Sy git
V. Installing Git on Gentoo
‘emerge’ is used to install Git on Gentoo
$sudo emerge –ask –verbose dev-vcs/git
- Installing Git on Mac OS
Git can be installed on Mac OS using Homebrew, MacPorts, or by the Git installer package.
But first of all, we need to precheck if Git is already installed in the system.
Check if Git is installed on Mac.
Here are the steps to check if Git is already installed on a Mac OS:
i. Using ‘git – – version’, check if Git is already installed on Mac OS.
If Git is not installed on your system, you will get the below message from the terminal:
ii. Click on the Install button to install the developer tools, which contain Xcode and Xcode app development utilities.
After following the steps, you will have a working Git version.
If Git is not installed in the system, follow these steps to install Git on Mac using Homebrew:
- In your Mac terminal, write the following command and execute it:
/bin/bash -c “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)”
- Press ‘Return’, and you will see an installation success message after the installation is done. You can install the recent Git version through the binary installer.
- Run Git after installation. Once Git is installed, you can set it up in your Mac system.
3. Installing Git on Windows
Installing Git on Windows is relatively easier. Follow the steps to make it done.
i. Go to the Git website’s ‘Download’ page.
ii. Double click on the recent Git version to download.
iii. Click on ‘Yes’ when you see an installation prompt.
iv. Click ‘Next’ to agree to the GNU license terms.
v. Select the system location you want Git to be installed.
vi. Select the Git components you wish to be installed in your system. Else, make the default selection.
vii. Choose the editor you want to be default for Git.
viii. Select how you want to use Git from the command line
ix. Select the SSL/TLS library for HTTPS connections.
x. Select how Git should treat the text files line endings.
xi. Select terminal emulator, the default behaviour of git pull, and extra configuring options. Click Install.
xii. Click Finish, and we are done with Git installation on Windows OS.
Git Set Up
After Git is installed in the system, you need to set it up and configure it.
$ git config — global user.name “Your Name”
$ git config — global user.email “your email address”
Git embeds the information we provide, i.e., name and email address.
You can use Git for version control after installing and setting up on your local system. You can also make open-source project contributions.
With this, you will be much involved in the broader developer community and ensure high-quality software for the users.
With the above installation methods, we hope you could easily install Git in your system.