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.

Note
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 Continue and then Agree to accept the license agreement:

    Agree to the license agreement.

  6. Click Continue to continue the installation:

    Click continue to continue the installation

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

    Change default location.

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

    Enter your password.

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

    Click close to exit.

  10. Open a terminal window.

  11. 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. Double click the .pkg file. A dialog window may appear stating that the file cannot be opened:

    A dialog may appear stating that the file cannot be opened

  4. Click on the Apple icon in the top left of the screen, and go to System Preferences > Security & Privacy. Click Open Anyway:

    Click on "Open Anyway" in the Security & Privacy preference window.

  5. Click on Open:

    Click on "Open"

  6. Click Continue button to begin the install:

    Click Continue

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

    Click "Continue" to use the default installation location.

  8. Enter your password when prompted, and then select Install Software:

    Enter your password

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

    Click on "Close" to complete the install

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. 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.

  6. 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.

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

    Select the start menu folder.

  8. Select the default text editor for Git, then click Next:

    Select the default text editor for Git.

  9. Adjust your PATH environment, then click Next:

    Adjust Git's PATH

  10. Choose which SSL/TLS library you’ll use for HTTPS. Then, click Next:

    Choose your HTTPS backend.

  11. 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.

    Note
    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.
  12. Choose the terminal emulator you’ll use, and then click Next:

    Select the terminal emulator you'll use.

  13. Configure the extra options, and then click Next:

    Configure the extra options.

  14. Check Launch Git Bash and complete the setup by selecting Finish:

    Complete the setup and launch the Git bash shell

  15. You can launch the Git GUI from the bash shell. Type git gui at the command line and hit enter:

    Launch the Git GUI by typing 'git gui' at the command line.

  16. Once you open Git you can select either Create New, Clone Existing or Open Existing Repository. In this example, we create new repository. Enter a directory name or click on Browse to navigate to a directory:

    Create New Repository.

  17. 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.

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