How to install Git
There are several ways to install Git on a Mac. In fact, if you’ve installed XCode (or it’s Command Line Tools), Git may already be installed. To find out, open a terminal and enter git –version.
$ git --version
git version 2.7.0 (Apple Git-66)
Apple actually maintain and ship their own fork of Git, but it tends to lag behind mainstream Git by several major versions. You may want to install a newer version of Git using one of the methods below:
Git for Mac Installer
The easiest way to install Git on a Mac is via the stand-alone installer:
Download the latest Git for Mac installer.
Follow the prompts to install Git.
Open a terminal and verify the installation was successful by typing git –version:
$ git --version
git version 2.9.2
Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com"
(Optional) To make Git remember your username and password when working with HTTPS repositories, configure the git-credential-osxkeychain helper.
Install Git with Homebrew
If you have installed Homebrew to manage packages on OS X, you can follow these instructions to install Git:
- Open your terminal and install Git using Homebrew:
$ brew install git
- Verify the installation was successful by typing which
git --version
:$ git --version
git version 2.9.2 - Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com" - (Optional) To make Git remember your username and password when working with HTTPS repositories, install the git-credential-osxkeychain helper.
Git for Windows stand-alone installer
- Download the latest Git for Windows installer.
- When you’ve successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finishprompts to complete the installation. The default options are pretty sensible for most users.
- Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt).
- Run the following commands to configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "yourname@email.com" - Optional: Install the Git credential helper on Windows
Bitbucket supports pushing and pulling over HTTP to your remote Git repositories on Bitbucket. Every time you interact with the remote repository, you must supply a username/password combination. You can store these credentials, instead of supplying the combination every time, with the Git Credential Manager for Windows.
Install Git on Linux
Debian / Ubuntu (apt-get)
Git packages are available via apt:
- From your shell, install Git using apt-get:
$ sudo apt-get update
$ sudo apt-get install git - Verify the installation was successful by typing
git --version
:$ git --version
git version 2.9.2 - Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com"
Fedora (dnf/yum)
Git packages are available via both yum and dnf:
- From your shell, install Git using dnf (or yum, on older versions of Fedora):
$ sudo dnf install git
or
$ sudo yum install git
- Verify the installation was successful by typing
git --version
:$ git --version
git version 2.9.2 - Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com"
[:en]
There are several ways to install Git on a Mac. In fact, if you’ve installed XCode (or it’s Command Line Tools), Git may already be installed. To find out, open a terminal and enter git –version.
$ git --version
git version 2.7.0 (Apple Git-66)
Apple actually maintain and ship their own fork of Git, but it tends to lag behind mainstream Git by several major versions. You may want to install a newer version of Git using one of the methods below:
Git for Mac Installer
The easiest way to install Git on a Mac is via the stand-alone installer:
Download the latest Git for Mac installer.
Follow the prompts to install Git.
Open a terminal and verify the installation was successful by typing git –version:
$ git --version
git version 2.9.2
Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com"
(Optional) To make Git remember your username and password when working with HTTPS repositories, configure the git-credential-osxkeychain helper.
Install Git with Homebrew
If you have installed Homebrew to manage packages on OS X, you can follow these instructions to install Git:
- Open your terminal and install Git using Homebrew:
$ brew install git
- Verify the installation was successful by typing which
git --version
:$ git --version
git version 2.9.2 - Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com" - (Optional) To make Git remember your username and password when working with HTTPS repositories, install the git-credential-osxkeychain helper.
Git for Windows stand-alone installer
- Download the latest Git for Windows installer.
- When you’ve successfully started the installer, you should see the Git Setup wizard screen. Follow the Next and Finishprompts to complete the installation. The default options are pretty sensible for most users.
- Open a Command Prompt (or Git Bash if during installation you elected not to use Git from the Windows Command Prompt).
- Run the following commands to configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "yourname@email.com" - Optional: Install the Git credential helper on Windows
Bitbucket supports pushing and pulling over HTTP to your remote Git repositories on Bitbucket. Every time you interact with the remote repository, you must supply a username/password combination. You can store these credentials, instead of supplying the combination every time, with the Git Credential Manager for Windows.
Install Git on Linux
Debian / Ubuntu (apt-get)
Git packages are available via apt:
- From your shell, install Git using apt-get:
$ sudo apt-get update
$ sudo apt-get install git - Verify the installation was successful by typing
git --version
:$ git --version
git version 2.9.2 - Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create:
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com"
Fedora (dnf/yum)
Git packages are available via both yum and dnf:
- From your shell, install Git using dnf (or yum, on older versions of Fedora):
$ sudo dnf install git
or
$ sudo yum install git
- Verify the installation was successful by typing
git --version
:$ git --version
git version 2.9.2 - Configure your Git username and email using the following commands, replacing Emma’s name with your own. These details will be associated with any commits that you create
$ git config --global user.name "Your Name"
$ git config --global user.email "name@email.com"