In this section, we will cover the steps required to install Git on different operating systems. By the end of this section, you will have Git installed and ready to use on your machine.

Table of Contents

Installing Git on Windows

Step-by-Step Guide

  1. Download the Git Installer:

  2. Run the Installer:

    • Locate the downloaded .exe file and double-click to run it.
    • Follow the installation wizard. You can generally accept the default settings, but here are a few key points:
      • Select Components: Ensure "Git Bash Here" and "Git GUI Here" are selected.
      • Adjusting your PATH environment: Choose "Use Git from the command line and also from 3rd-party software".
      • Configuring the line ending conversions: Choose "Checkout Windows-style, commit Unix-style line endings".
  3. Complete the Installation:

    • Click "Install" and wait for the process to complete.
    • Once done, click "Finish".

Practical Example

# Open Git Bash (installed with Git)
$ git --version

This command should output the installed Git version, confirming the installation.

Installing Git on macOS

Step-by-Step Guide

  1. Using Homebrew (Recommended):

    • If you don't have Homebrew installed, you can install it by running the following command in the Terminal:
      /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
      
    • Once Homebrew is installed, install Git by running:
      brew install git
      
  2. Using the Git Installer:

    • Go to the official Git website: https://git-scm.com/
    • Click on the "Download" button for macOS.
    • Open the downloaded .dmg file and follow the instructions to install Git.

Practical Example

# Open Terminal
$ git --version

This command should output the installed Git version, confirming the installation.

Installing Git on Linux

Step-by-Step Guide

  1. Using Package Managers:

    • Debian/Ubuntu:
      sudo apt update
      sudo apt install git
      
    • Fedora:
      sudo dnf install git
      
    • Arch Linux:
      sudo pacman -S git
      
  2. Building from Source:

    • Download the latest version from the official Git website: https://git-scm.com/
    • Extract the tarball and navigate to the directory:
      tar -xf git-<version>.tar.gz
      cd git-<version>
      
    • Compile and install:
      make prefix=/usr/local all
      sudo make prefix=/usr/local install
      

Practical Example

# Open Terminal
$ git --version

This command should output the installed Git version, confirming the installation.

Verifying the Installation

After installing Git, it's important to verify that the installation was successful and that Git is accessible from the command line.

Steps to Verify

  1. Open your terminal or command prompt.
  2. Run the following command:
    git --version
    

Expected Output

You should see an output similar to the following, indicating the installed version of Git:

git version 2.33.0

Conclusion

In this section, we covered the steps to install Git on Windows, macOS, and Linux. We also verified the installation to ensure Git is correctly set up on your system. With Git installed, you are now ready to move on to the next section, where we will explore basic Git terminology.

© Copyright 2024. All rights reserved