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 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:
- Download the latest Git for Mac installer.
- Follow the given instructions to finish installing.
- Open the terminal and type git --version to verify that the installation was successful.
git --version git version 2.9.2
- 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:
- Open your terminal and install Git with Homebrew.
brew install git
- Type git --version to verify that the installation was successful.
git --version git version 2.9.2
- 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:
- Update MacPorts:
sudo port selfupdate
- Now you need to search the most recent Git ports and variants:
port search git port variants git
- 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
- 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:
- Download the most recent Git for Windows installer.
- Then, the Git Setup wizard screen will show up and you need to follow the prompts to complete the installation.
- Open a Command Prompt or Git Bash if you’ve selected not to use Git from Windows Command Prompt.
- 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:
- Install Git from your shell with apt-get:
sudo apt-get update sudo apt-get install git
- Type git --version to verify that the installation has succeeded:
git --version git version 2.9.2
- 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.
- Install Git using dnf or use yum if you’re using older versions of Fedora.
sudo dnf install git
sudo yum install git
- Type git --version to verify that the installation was successful.
git --version git version 2.9.2
- 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
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.