Installing Git: A Cross-Platform Guide

Alright, you're sold on the idea of Git! You understand why version control is essential for any professional project. The next logical step is to get the actual Git software installed on your computer so you can start using it.

This lesson is a straightforward, practical guide to getting Git set up on your machine, whether you're using Windows, macOS, or Linux. We'll also cover the one-time configuration you must perform after installation to ensure your commits are attributed to you.

Let's get your development environment ready for version control! 🛠️

Installing Git on Windows

For Windows and Mac users, there are two excellent ways to get Git installed on your system. You can use the official command-line installer, or you can use a visual Git client like Atlassian Sourcetree, which bundles Git within it.

Method 1: Git for Windows (Command-Line Focused)

This is the standard approach if you're comfortable working with a terminal and want the official Git package.

  1. Download the Installer: Navigate to the official Git download page and grab the latest installer for Windows.
    Official Git for Windows Download Page
  2. Run the Installer: Launch the downloaded file. You'll be presented with a series of setup screens. While the default options are excellent for most users, there are a couple you should pay special attention to.

Navigating the Installer Options

The Git for Windows installer is very powerful. For beginners, the recommended defaults are almost always the right choice. Here are two key steps where you might want to make a change:

  • Choosing the Default Editor: It is highly recommended to use the dropdown menu to select a familiar editor, like Visual Studio Code, if you have it installed.
  • Adjusting your PATH environment: The recommended default option ("Git from the command line and also from 3rd-party software") is the best choice. This ensures you can type git commands in any terminal, like Command Prompt or PowerShell, and have them work correctly.

For all other screens, the default selections are perfectly fine. Simply click "Next" through the remaining steps and finally "Install".

Method 2: Install Git with Atlassian Sourcetree (GUI Focused)

If you prefer a visual interface for managing your repositories instead of the command line, I highly recommend using Sourcetree. It's a powerful and free visual Git client that I use in my day-to-day operations. The best part is that it comes with its own bundled version of Git, so the installation handles everything for you.

  1. Download Sourcetree: Go to the official Sourcetree website and download the installer.
    Download Atlassian Sourcetree
  2. Run the Installer: Follow the on-screen instructions. The setup process is very straightforward. It will register you with an Atlassian account and then guide you through the installation of both Sourcetree and the bundled Git.

Using Sourcetree gives you a user-friendly graphical interface for all your Git commands, which can make learning version control much more intuitive.

Installing Git on Mac OS X

On Mac OS X, there are a few easy ways to install Git. Often, it might already be installed with XCode!

Method 1: XCode Command Line Tools (Easiest)

The simplest way is to just try using Git. Open the Terminal app (you can find it in Applications > Utilities, or search for it with Spotlight) and type:

git --version

If you don't have Git installed, macOS will likely pop up a dialog box prompting you to install the "command line developer tools." Click "Install" and agree to the terms. This package from Apple includes Git along with other essential development tools.

Method 2: Using Homebrew (Recommended for Power Users)

If you are a more advanced user or plan to install other development software, Homebrew, the "missing package manager for macOS," is an excellent tool. If you have Homebrew installed, you can easily install Git with a single command in your terminal:

brew install git

Method 3: Official Installer

You can also download a dedicated installer for macOS directly from the Git website, which works similarly to the Windows installer.

Official Git for macOS Download Page

Method 4: Install Git with Atlassian Sourcetree

As mentioned earlier, Sourcetree is a visual Git client that simplifies Git operations for users who prefer a graphical interface. If you choose to install Git through Sourcetree, the process is simple – Git is bundled with the installer, so everything is handled in one go.

  1. Download Sourcetree: Go to the official Sourcetree website and download the installer.
    Download Atlassian Sourcetree
  2. Run the Installer: Follow the on-screen instructions. The setup process is very straightforward. It will register you with an Atlassian account and then guide you through the installation of both Sourcetree and the bundled Git.

Installing Git on Linux (Debian/Ubuntu)

Most Linux distributions come with a built-in package manager that makes installing Git very simple. For Debian-based distributions like Ubuntu, you use the apt package manager.

Open your terminal and run the following commands:

# First, update your package list to make sure you get a recent version
sudo apt update
 
# Then, install git
sudo apt install git -y

If you are using a different Linux distribution, you would use its corresponding package manager (e.g., sudo dnf install git on Fedora/CentOS).

Verifying Your Installation

Once the installation is complete on any operating system, the final step is to verify that it worked correctly. Open a new terminal or command prompt window (this is important, as it ensures it uses the updated system PATH).

Type the following command and press Enter:

git --version

You should see a message indicating the installed Git version, like this:

git version 2.50.0.windows.1

The exact version number isn't critical, as long as it doesn't report an error like "command not found." If you see a version number, you're all set!

Essential First-Time Configuration

Before you make your first commit, there's one final, crucial step. You need to tell Git who you are. This information will be baked into every single commit you create, so it's important to set it up correctly.

You only need to do this once on your machine. Open your terminal or command prompt and run the following two commands, replacing the example text with your actual name and email address. Use the same email address that you will use for your GitHub account.

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

The --global flag tells Git to use this information for every repository on your computer. This configuration is saved in a special .gitconfig file in your user's home directory.

With this done, your Git installation is now fully prepared for action!

Key Takeaways

  • You can install Git on any major operating system (Windows, macOS, Linux) by downloading the official installer or using a package manager like Homebrew or apt.
  • During Windows installation, it's recommended to select a familiar default editor (like VS Code) and use the recommended PATH setting.
  • After installation, you can verify that Git is working by opening a new terminal and running the git --version command.
  • The most critical first-time setup step is configuring your user name and email using the git config --global command.

Installation Resources

What's Next?

Excellent! Your development environment is now equipped with the most important tool for modern software development. With Git installed and configured, you're ready to start using it to track your projects. In our next lesson, we'll get hands-on and learn the most important day-to-day commands as we explore the Basic Git Commands & The Commit Lifecycle.