Header

How to install Git

Step-by-step instructions to install and configure Git.

Introduction

The process for installing Git differs slightly between operating systems.

Install Git on Windows

There are a couple of different ways to install Git on Windows. We recommend using an unofficial installer called msysGit.

To get started, head over to their website, download their installer and install it onto your computer.

msysGit Installer

Verify installation on Windows

To verify that Git has been installed, open the Command Prompt from Start > Windows System, or by pressing Windows + R then typing cmd and clicking OK.

Windows Command Prompt

Enter the following command:

git --version

If installed properly, you should see some output like this:

git version 2.15.1

You're now ready to add some global configuration for Git.

Install Git on Mac

Option 1 - Command Line Tools for Xcode

Open the Terminal app which can be found in Applications > Utilities. In the window that appears, enter the following command and press return:

git --version

If Git has already been installed, you'll see some output like this:

git version 2.15.1

However, if it hasn't you'll be prompted to install the Command Line Tools.

Option 2 - Git Installer for Mac

Alternatively, there's an official Git installer for macOS.

Once it's finished downloading, open the installer, and follow the installation wizard using all the default options and preferences.

Verify installation on Mac

To verify that Git has been installed successfully, open up the Terminal app and enter the following command:

git --version

If installed properly, you should see some output like this:

git version 2.15.1

You're now ready to add some global configuration for Git.

Install Git on Linux

Open up your preferred terminal emulator and run the following commands:

# Debian/Ubuntu
sudo apt-get update
sudo apt-get install git

# Fedora
sudo dnf install git

Verify installation on Linux

To verify that Git has been installed properly, run the following command:

git --version

If installed properly, you should see some output like this:

git version 2.15.1

You're now ready to add some global configuration for Git.

Global configuration for Git

Once you've verified that Git has been installed successfully, open the Terminal (Command Prompt if you're on Windows) and run the following two commands to configure Git to use your name and e-mail address:

git config --global user.name "Your Name"
git config --global user.email "you@example.com"

This will create a hidden file called .gitconfig in your home directory which will contain contents similar to the following:

[user]
    name = Your Name
    email = you@example.com

This information is used by Git to populate the author information when you save your changes in the form of commits.

Both your name and e-mail address will be visible to anyone who has access to your repositories, so make sure you're using an e-mail address you don't mind sharing!

You're now ready to create your first Git repository.

Want to learn more about Git?

This tutorial is part of a free beginner-friendly course!

Learn More

Proudly powered by Katapult. Running on 100% renewable energy.