New users get $100 in free credits for 30 daysGet Started

Introducing local edge computing in 5 new African citiesLearn More

Join our webinar: Scaling your startup on African infrastructureRegister Now

How to Install Git on Linux, Windows, and macOS

John Doe
John Doe
December 15, 2024
10 min read
GitVersion ControlDevelopment ToolsBeginner

Introduction to Git

Git is a distributed version control system that tracks changes in source code during software development. It's designed for coordinating work among programmers, but it can be used to track changes in any set of files. Git was created by Linus Torvalds in 2005 for development of the Linux kernel.

In this tutorial, we'll walk through the process of installing Git on the three major operating systems: Linux, Windows, and macOS. By the end of this guide, you'll have Git installed and configured on your system.

Prerequisites

Before we begin, make sure you have:

  • Administrative access to your computer
  • An active internet connection
  • Basic familiarity with command line interface (helpful but not required)

Installing Git on Linux

Most Linux distributions include Git in their package repositories. The installation method depends on your distribution's package manager.

Ubuntu/Debian

For Ubuntu, Debian, and other Debian-based distributions:

Terminal
# Update package index
sudo apt update

# Install Git
sudo apt install git

CentOS/RHEL/Fedora

For Red Hat-based distributions:

Terminal
# For CentOS/RHEL 7 and older
sudo yum install git

# For CentOS/RHEL 8+ and Fedora
sudo dnf install git

Arch Linux

For Arch Linux and Arch-based distributions:

Terminal
sudo pacman -S git

Installing Git on Windows

There are several ways to install Git on Windows. The most common method is to download the official installer from the Git website.

  1. Download Git for Windows

    Visit the official Git website at git-scm.com/download/winand download the latest version for your system (32-bit or 64-bit).

  2. Run the Installer

    Double-click the downloaded .exe file to start the installation process. You may need to grant administrator permissions.

  3. Configure Installation Options

    The installer will present several configuration options. For most users, the default settings are recommended:

    • Select components: Keep all default selections
    • Default editor: Choose your preferred text editor
    • PATH environment: Select "Git from the command line and also from 3rd-party software"
    • HTTPS transport backend: Use the OpenSSL library
    • Line ending conversions: Checkout Windows-style, commit Unix-style line endings
  4. Complete Installation

    Click "Install" and wait for the process to complete. Once finished, you can optionally launch Git Bash or view the release notes.

Alternative Installation Methods

You can also install Git on Windows using package managers like Chocolatey or Scoop:

  • Chocolatey: choco install git
  • Scoop: scoop install git

Installing Git on macOS

There are several ways to install Git on macOS. Here are the most common methods:

Method 1: Using Homebrew (Recommended)

If you have Homebrew installed, this is the easiest method:

Terminal
# Install Homebrew if you haven't already
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Git
brew install git

Method 2: Using Xcode Command Line Tools

macOS includes a version of Git with Xcode Command Line Tools:

Terminal
xcode-select --install

Method 3: Download from Git Website

You can also download the official installer from git-scm.com/download/macand follow the installation wizard.

Verify Installation

After installing Git, verify that it's working correctly by checking the version:

Terminal
git --version

You should see output similar to:

Output
git version 2.39.0

Initial Configuration

Before using Git, you should configure your identity. This information will be associated with your commits:

Terminal
# Set your name
git config --global user.name "Your Name"

# Set your email
git config --global user.email "your.email@example.com"

# Set default branch name (optional)
git config --global init.defaultBranch main

# Verify configuration
git config --list
Success!

Congratulations! You now have Git installed and configured on your system. You're ready to start using version control for your projects.

Conclusion

In this tutorial, we've covered how to install Git on Linux, Windows, and macOS. We've also shown you how to verify the installation and perform initial configuration.

Now that you have Git installed, you can start learning about basic Git commands and workflows. Some next steps you might consider:

  • Learn basic Git commands (init, add, commit, push, pull)
  • Create your first Git repository
  • Set up a GitHub or GitLab account
  • Explore Git branching and merging

About the Author

John Doe
John Doe
Senior DevOps Engineer with 8+ years of experience in cloud infrastructure and development tools.

Need Help?

Get expert assistance with your cloud infrastructure setup.

Contact Support