How to Install Git on Linux, Mac or Windows
Updated by Linode Written by Linode
Introduction to Git
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.
NoteThis guide will usesudo
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.
- Go to the Homebrew website.
Copy and paste the command on that page, under Install Homebrew into a terminal window:
At the next prompt enter your password and hit Return:
You will receive an installation successful message when complete:
To help diagnose Homebrew errors, install Brew Doctor before installing Git:
Update Homebrew:
brew update
Install Git:
brew install git
Install Git via MacPorts
If MacPorts is already installed, proceed directly to Step 9.
- Go to MacPorts website.
- Click on the link for your operating system.
- After the download completes, click on the file to start the installer.
Click the Continue button to begin the install:
Click Continue and then Agree to accept the license agreement:
Click Continue to continue the installation:
To leave the default installation location click Install, or to change the default installation location, click Change Install Location:
Enter your password when prompted and click Install Software:
After the installation completes, click Close to exit the installer:
Open a terminal window.
Install Git:
sudo port install git +svn +doc +bash_completion +gitweb
Install Git via Package Installer
- Go to the Git website and download the current installer for your operating system.
- Double click on the downloaded file to begin the install.
Double click the
.pkg
file. A dialog window may appear stating that the file cannot be opened: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:
Click Continue button to begin the install:
To leave the default installation location click Install, or to change the default installation location, click Change Install Location:
Enter your password when prompted, and then select Install Software:
After the installation completes, click Close to exit the installer:
To install Git on Windows you will need to download the installer from the Git website:
Download the most current version for your operating system by double clicking on the package name:
Select Run to begin the installation:
Click Yes to continue:
Click Next to continue:
If you need to change the installation folder, click Browse and select a new location. To accept the default location click on Next:
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 Start Menu folder by clicking Next, or use Browse to select a new folder location:
Select the default text editor for Git, then click Next:
Adjust your PATH environment, then click Next:
Choose which SSL/TLS library you’ll use for HTTPS. Then, click Next:
Keep the default line ending conversion by clicking Next. To change the default, choose one of the two other choices before clicking Next:
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.Choose the terminal emulator you’ll use, and then click Next:
Configure the extra options, and then click Next:
Check Launch Git Bash and complete the setup by selecting Finish:
You can launch the Git GUI from the bash shell. Type
git gui
at the command line and hit enter: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:
A blank repository is created:
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.