Working with Git starts with installing or updating, if you already have it on your computer. On this page, you will find how to install Git on Windows, Linux and Mac.

how to install git

How to Install Git on Mac

There are three ways to install Git on Mac OS X: Git for Mac installer, Homebrew and MacPorts.

Mac Installer

This is the simplest way of installing Git on Mac. Here are the steps to follow:

  1. Download the latest Git for Mac installer.
  2. Follow the given instructions to finish installing.
  3. Open the terminal and type git --version to verify that the installation was successful.
    git --version
    git version 2.9.2
  4. Input your Git username and email as given in the example below:
    git config --global user.name "BobSmith001"
    git config --global user.email "[email protected]"

Homebrew

Install Homebrew on Mac and then follow the steps below to install Git with it:

  1. Open your terminal and install Git with Homebrew.
    brew install git
  2. Type git --version to verify that the installation was successful.
    git --version
    git version 2.9.2
  3. You need to input your Git username and email as given in the example below:
    git config --global user.name "BobSmith001"
    git config --global user.email "[email protected]"

MacPorts

Follow these instructions to install Git with MacPorts:

  1. Update MacPorts:
    sudo port selfupdate
  2. Now you need to search the most recent Git ports and variants:
    port search git
    port variants git
  3. The installation of Git should be with bash completion, the OS X keychain helper, and the docs:
    sudo port install git +bash_completion+credential_osxkeychain+doc
  4. You need to configure your Git username and email as given in the example below:
    git config --global user.name "BobSmith001"
    git config --global user.email "[email protected]"

How to Install Git on Windows

Find the instructions below to install Git on Windows:

  1. Download the most recent Git for Windows installer.
  2. Then, the Git Setup wizard screen will show up and you need to follow the prompts to complete the installation.
  3. Open a Command Prompt or Git Bash if you’ve selected not to use Git from Windows Command Prompt.
  4. Configure your Git username and email as given in the example below:
    git config --global user.name "BobSmith001"
    git config --global user.email "[email protected]"

How to Install Git on Linux

Debian / Ubuntu ( apt-get )

You can find Git packages via APT. Here are the steps to follow:

  1. Install Git from your shell with apt-get:
    sudo apt-get update
    sudo apt-get install git
  2. Type git --version to verify that the installation has succeeded:
    git --version
    git version 2.9.2
  3. Input your Git username and email as given in the example below:
    git config --global user.name "BobSmith001"
    git config --global user.email "[email protected]"

Fedora (dnf/yum)

Git packages are available via yum and dnf.

  1. Install Git using dnf or use yum if you’re using older versions of Fedora.
    sudo dnf install git
    sudo yum install git
  2. Type git --version to verify that the installation was successful.
    git --version
    git version 2.9.2
  3. Configure your Git username and email as given in the example below:
    git config --global user.name "BobSmith001"
    git config --global user.email "[email protected]"

    How to Install Git From Source on Linux

    Installing Git from source is more preferable, as you can always get the latest and updated version. You need the following libraries to install Git from source: curl, zlib, openssl, expat and libiconv. For those, who use a system that has dnf or apt-get, the two commands below can be useful for installing all of the dependencies:

    Note that you will need the following additional dependencies to be able to add documentation in different formats (doc, HTML, info):

    yum install curl-devel expat-devel gettext-devel \
    openssl-devel zlib-devel perl-devel asciidoc xmlto
    apt-get install libcurl4-gnutls-dev libexpat1-dev gettext \
    libz-dev libssl-dev
    sudo dnf install asciidoc xmlto docbook2X
    sudo apt-get install asciidoc xmlto docbook2x

    Compile and install:

    tar -zxf git-1.7.2.2.tar.gz
    cd git-1.7.2.2
    make prefix=/usr/local all
    sudo make prefix=/usr/local install

    Git can also be installed via Git itself for updates:

    git clone git://git.kernel.org/pub/scm/git/git.git

Practice Your Knowledge

Which methods can be used to install Git on different operating systems?

Quiz Time: Test Your Skills!

Ready to challenge what you've learned? Dive into our interactive quizzes for a deeper understanding and a fun way to reinforce your knowledge.

Do you find this helpful?