Git Installation

Learn via video courses
Topics Covered

Overview

Git is the most widely used free and open-source distributed version control system used to efficiently handle small to very large projects. It is used to track the changes in the source code and projects across different teams and revision levels. Git enables multiple developers to work together on a non-linear parallel development basis.

To use Git, you need to install it on your computer. If you already have git installed on your machine, it is recommended to update it to the latest version. You can install it as a package, install it from another installer, or download it from the official website. This article covers the Git installation process for various operating systems and key troubleshooting points for various package managers.

Pre-requisites

One of the most important tools developers use in their software development journey is a version control system (VCS). This is a basic thing that every developer should know.

Along with CVS (Concurrent Versions System), Mercurial, and SVN (Apache Subversion), Git is one of the most popular version control systems and a favorite among developers around the world.

Git is an open-source tool. This means it's completely free to use and can even be customized to suit your specific needs. It also includes a variety of features aimed at streamlining project workflows while enabling collaboration between individual developers and teams.

Whether you're a novice with little knowledge of version control systems or a pro looking to move to Git, you've made the right choice. Git is not only easy to learn and use, but also it's an in-demand skill.

This comprehensive guide takes a deep dive into Git and highlights everything that will help you get started with this immensely popular version control system.

Introduction to the Git Installation

You can install git as a package or via another installer or you can directly download it from its official site. However, to check if Git is already installed on your computer, open a terminal if you're using a Mac or Linux, or open a command prompt if you're using a Windows operating system. After opening the Terminal application, enter the following command:

If git is already installed on your computer then the output will tell you which version of Git is installed, or if it is not installed there then it will alert you that git is an unknown command. If it is an unknown command then proceed to the next sections to learn about the steps to install git on the machine.

Git Installation on Windows

  1. To install git, firstly go to the official Git website: git website.

  2. Then Click the download link for Windows and wait for the download to complete. git-download-option-for-different-operating-systems

  3. Navigate to where the download was made.

  4. Now extract and launch the installer by double-clicking the file. installer-location

  5. Now, allow the app to make changes to your device by clicking Yes on the User Account Control dialog that opens and this will initiate the Git installation process after selecting Yes. user-account-control-box

  6. Review the General Public License Guidelines (GNU), and when you’re ready to install, click Next. general-public-license-guidelines

  7. Then, the installer will ask for the installation location. If you don't need a specific location, leave the default and click Next. select-destination-location-box-for-installer

  8. The component selection screen will appear so you can select and check the desired components. Unless you have special requirements, leave the default settings and click Next. components-selection-box

  9. The installer will then offer to create a start menu folder. Simply click Next. start-menu-folder

  10. You can now choose which text editor to use with Git. To do this, use the dropdown menu to select Notepad++ (or any of your preferred text editors) and click Next. using-text-editor-with-git

  11. In the next step you can choose another name for the first branch beside the default name "Master". This is useful when working in teams. Otherwise, leave the default options and click Next. changing-branch-name

  12. The installation procedure now allows you to change the PATH environment. PATH is the default set of directories included when running a command from the command line. Leave this as the middle (recommended) selection and click Next. changing-path-for-installation

  13. The installer will ask which SSH client to use with Git. Git already comes with an SSH client. So if you don't want a particular option, just leave the default option and click Next.

    ssh-option

  14. The next option relates to the server certificates. Most users should use the default. next-option-relates-to-the-server-certificates

  15. If you are working in an Active Directory environment, you may need to switch to Windows store certificates. next click. switch-to-windows-store-certificates

  16. The next selection converts line endings. It is recommended that you leave the default selection.

  17. This relates to the way data is formatted and changing this option may cause problems. Click Next. this-relates-to-the-way-data-is-formatted

  18. Choose the terminal emulator you want to use. The default MinTTY is recommended, for its various features. Click Next. choose-the-terminal-emulator

  19. The installer will ask you what you want to do with the git pull command. We recommend the default options unless you specifically need to change the behavior. Click Next to continue the installation. choose-what-do-you-want-to-do-with-git-pull

  20. Next you will be shown to choose which credential helper to use.

  21. Git uses credential helpers to fetch or save credentials. Leave the default option as it is the most stable one, and click Next.

    git-uses-credential-helpers-to-fetch

How Do Add Some Additional Customization Options?

Now, you will see some additional adjustments. Default options are recommended, but in this step, you can decide which additional options to enable. Check the box if you are using symbolic links like command line shortcuts. Now, click next.

how-to-add-some-additional-customization-options

Depending on the version of Git you install, you may be prompted to install experimental features. If you don't want to be adventurous, leave them unchecked and click Install.

how-to-add-some-additional-customization-options-2

Now, to complete the installation process, check the boxes to view the Release Notes or Launch Git Bash, then click Finish.

how-to-add-some-additional-customization-options-3

After clicking finish, you should have a working Git installation on your Windows machine. how-to-add-some-additional-customization-options-4

How to Launch Git on Windows?

There are two modes to launch git in windows one is using the graphical user interface (GUI) and the other is using a bash scripting shell (or command line). We will look at each of these methods:

Launch git using the graphical user interface (GUI):

To launch Git GUI open the Windows Start menu, type git GUI, and press Enter (or click the application icon).

launch-git-using-the-graphical-user-interface

It comes with three features.

  1. Create New Repository
  2. Clone Existing Repository
  3. Open the Existing Repository

Launch git using bash shell:

To launch Git using Bash, open the Windows Start menu, type git bash, and press Enter (or click the application icon).

launch-git-using-bash-shell

The git bash looks like this:

launch-git-using-bash-shell-2

How to Update Git on Windows?

The above steps were for the fresh git installation on your machine, but if you are already having git installed on your computer and just want to update it, then you can skip the above steps and follow the procedure below to upgrade the version of git in the machine.

To know the current version of git installed in the machine, you can type the command:

It will display the version of git on your machine. To update the versions before 2.14.1, you just have to uninstall Git from your system and install a copy of the latest version from scratch.

But, if your version lies between 2.14.2 and 2.16.1, then you can use the following command in your command prompt and it will directly update the git version to the latest one:

For all the versions above 2.16.1, you can update Git with:

Install Git on Mac

Most of the versions of the Mac operating system will already have Git installed, and you can activate it through the terminal with the git version. But, if you don't have Git installed for whatever reason, then you can install the latest version of Git using one of several popular methods as listed below:

We will see a few common methods to install git on mac OS:

1. Install Git from an Installer

  1. Download the latest Git for Mac installer.

  2. Once the installer has started, follow the instructions as provided until the installation is complete.

  3. Open a terminal and verify the installation was successful by typing git --version.

  4. Use the following commands to configure your Git username and email address, replacing the dummy name and email address with your own. These details map to each commit you create:

2. Install Git with Homebrew

Homebrew is a popular package manager for macOS. If you don't have homebrew manager installed then you can install it using the below command and can then proceed with the git installation steps. If you already have Homebrew installed, you can directly follow the steps to install Git.

To install homebrew:

Steps for installing git with Homebrew package manager:

  1. Open your terminal and install Git using Homebrew:

  2. Verify the installation was successful by typing git --version.

  3. Use the following commands to configure your Git username and email address, replacing the dummy name and email address with your own. These details map to each commit you create:

3. Install Git with MacPorts

If you have MacPorts installed to manage your packages on OS X, you can install Git by following these steps:

  1. Open your terminal and update MacPorts using this command:

  2. Search for the latest available Git ports and variants by typing these commands:

  3. Install Git with bash completion, macOS Keychain Utilities, and documentation:

  4. Now, use the following commands to configure your Git username and email address, replacing the dummy name and email address with your own. These details map to each commit you create:

How to Update Git on MacOS?

The above steps were for the fresh git installation on your machine, but if you are already having git installed on your computer and just want to update it, then you can skip the above steps and follow the procedure below to upgrade the version of git in the machine.

To know the current version of git installed in the machine, you can type the command:

To update the git to the latest version, you can use this command:

Then, check the current Git version to confirm the update:

Git Installation on Linux

The below steps for installing Git on Linux depend on which Linux distribution you are using. This section shows you how you can install Git on Ubuntu, Fedora, and Arch Linux.

Installing Git on Ubuntu or Debian

  1. Git packages are available using apt.

  2. It's a good idea to make sure you're running the latest version.

  3. To do so, Navigate to your command prompt shell and run the following command to make sure everything is up-to-date:

  4. Now, to install Git, run the following command:

  5. Once the command output has been completed, you can verify the installation by typing

  6. Use the following commands to configure your Git username and email address, replacing the dummy name and email address with your own. These details map to each commit you create:

Installing Git on Fedora

  1. Git packages are available using dnf.

  2. To install Git, navigate to your command prompt shell and run the following command:

    or you can also do the installation using yum on the older versions of Fedors using the command:

  3. Once the command output has been completed, you can verify the installation by typing:

  4. Use the following commands to configure your Git username and email address, replacing the dummy name and email address with your own. These details map to each commit you create:

Installing Git on Arch Linux

To install git on Arch Linux, you can make use of the pacman, and install it using the command:

Installing Git on Gentoo

To install git on Gentoo, you can make use of the emergency, and install it using the command:

How to Update Git on Linux?

The above steps were for the fresh git installation on your machine, but if you are already having git installed on your computer and just want to update it, then you can skip the above steps and follow the procedure below to upgrade the version of git in the machine.

To know the current version of git installed in the machine, you can type the command:

To update the git to the latest version, update the system packages with the following command:

Then you can use this command to update the version of git to the latest version:

To verify the update, check the Git version one more time:

Conclusion

  • Git is the most widely used free and open-source distributed version control system used to handle small to very large projects efficiently.
  • It is used to track the changes in the source code and projects across different teams and revision levels.
  • Git enables multiple developers to work together on a non-linear parallel development basis.
  • Few of the primary advantages of git are its ease to use, Widespread Popularity, Free and Open-Source, Compatibility with All Popular Operating Systems, security, and reliability.
  • It provides a way to track previous versions of software and articles, facilitate collaboration between different authors, and provide software backups.
  • To see if Git is installed on your system, open your terminal and type git --version.
  • If your terminal returns a Git version as an output, that confirms you have Git installed on your system. If not, you have to download Git for Mac or Windows.
  • After following this tutorial, you should have a fully updated version of Git installed on a Linux, Windows, or macOS machine.
  • To install git on the mac operating system, we saw three methods i.e via the installer, MacPorts, and Homebrew.
  • We saw the installation steps in Linux for different distributions like Fedora, Arch Linux, Gentoo, and Ubuntu.
  • Homebrew is a package manager used to simplify software installation.
  • We saw some additional customization options in windows along with the steps to launch git on the windows operating system.
  • We saw the methods to upgrade the git version in Windows, Linux, and macOS.