How to Install Git on Linux, Mac or Windows

Updated by Linode Written by Linode

Contribute on GitHub

Report an Issue | View File | Edit File

Introduction to Git

How to Install Git on Linux, Mac or Windows

Git was designed and developed by Linus Torvalds for Linux kernel development. Git provides support for non-linear, distributed development, allowing multiple contributors to work on a project simultaneously. Git is the most popular distributed version control and source code management system.

This guide explains how to install the latest, stable, prepackaged version git on GNU/Linux, Mac Osx, and Windows, using their respective package managers. Git can also be compiled from source and installed on any operating system.

For more information about using and configuring Git, see our Getting Started with Git guide.

This guide will use sudo wherever possible. Complete the sections of our Securing Your Server to create a standard user account.

Install Git

  • Debian and Ubuntu:

    sudo apt-get install git
  • CentOS:

    sudo yum install git
  • Fedora:

    sudo yum install git-core
  • Arch Linux:

    sudo pacman -Sy git
  • Gentoo:

    sudo emerge --ask --verbose dev-vcs/git

There are different ways to install Git on Mac OS. You can install Git using Homebrew, MacPorts, or by downloading the Git installer package.

Install Git via Homebrew

If Homebrew is already installed, begin with Step 6.

  1. Go to the Homebrew website.
  2. Copy and paste the command on that page, under Install Homebrew into a terminal window:

    Enter the install command.

  3. At the next prompt enter your password and hit Return:

    Enter your password.

  4. You will receive an installation successful message when complete:

    Enter your password.

  5. To help diagnose Homebrew errors, install Brew Doctor before installing Git:

    Install brew doctor.

  6. Update Homebrew:

    brew update

    Update Homebrew.

  7. Install Git:

    brew install git

Install Git via MacPorts

If MacPorts is already installed, proceed directly to Step 9.

  1. Go to MacPorts website.
  2. Click on the link for your operating system.
  3. After the download completes, click on the file to start the installer.
  4. Click the Continue button to begin the install:

    Begin MacPort install.

  5. Click Agree to accept the license agreement:

    Agree to the license agreement.

  6. To leave the default installation location click Install, or to change the default installation location, click Change Install Location:

    Change default location.

  7. Enter your password when prompted and click Install Software:

    Enter your password.

  8. After the installation completes, click Close to exit the installer:

    Click close to exit.

  9. Open a terminal window.

  10. Install Git:

    sudo port install git +svn +doc +bash_completion +gitweb

Install Git via Package Installer

  1. Go to the Git website and download the current installer for your operating system.
  2. Double click on the downloaded file to begin the install.
  3. Click on the Continue button to begin the install:

    Click on continue.

  4. Select Install for all users of this computer and click Continue to begin the installation:

    Click on install for all users of this computer.

  5. If you need to change the installation location click Change Install Location button. Click Install to continue with the default location:

    Click on change install location.

  6. Enter your username and password and click Install Software to continue:

    Enter username and password and click install software.

  7. Click the Close button to exit the installer:

    Click close to exit.

To install Git on Windows you will need to download the installer from the Git website:

  1. Download the most current version for your operating system by double clicking on the package name:

    Click to download version for Windows.

  2. Select Run to begin the installation:

    Click Run to start the installer.

  3. Click Yes to continue:

    Click Yes to continue.

  4. Click Next to continue:

    Click Next to continue.

  5. Click Next to continue:

    Click Next to continue.

  6. If you need to change the installation folder, click Browse and select a new location. To accept the default location click on Next:

    Click Next for default or Browse to change.

  7. To accept the default components to be installed click Next. Otherwise, select the additional components to be installed before clicking the Next button:

    Accept the default or select additional components.

  8. Accept the default Start Menu folder by clicking Next, or use Browse to select a new folder location:

    Select the start menu folder.

  9. Keep the default line ending conversion by clicking Next. To change the default, choose one of the two other choices before clicking Next:

    Select line ending conversions.

    It is strongly recommended that you keep the default settings for line ending conversions. Changing from the default may result in formatting problems when viewed on your Linode.
  10. The program will now begin installing:

    Git is installing.

  11. Click Finish to exit the installer:

    Click Finish to exit.

  12. Once you open Git you can select either Create New, Clone Existing or Open Existing Repository. In this example, we create new repository:

    Create New Repository.

  13. Enter a directory name or click on Browse to navigate to a directory:

    Directory for a new repository.

  14. A blank repository is created:

    Blank repository.

Get Started with Git

Visit our guide on Git configuration for helpful commands to get you started with Git and repositories.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

Join our Community

Find answers, ask questions, and help others.

comments powered by Disqus

This guide is published under a CC BY-ND 4.0 license.