Install Git

Needs revision -- Last peer review: 16 Aug 2019
Install Git on your personal computer

While climbing the Drupal Ladder, Git gives you easy ways to manage changes to the code: you can apply a patch for testing, tweak the patch, experiment, re-roll it, and get back safely to where you started.

This lesson will help you install Git so that you can use it from the command line. GUI versions also exist, but for basic operations it is generally held that the command line is simpler. When you get instructions on, while climbing the Drupal Ladder, or when asking for advice on how to use Git, the instructions will assume a command line.
Some steps are specific to your platform. The following platforms are covered in this lesson:

  • Mac OS X
  • Windows
  • Linux

Note: instructions on command line tools commonly include the prompt, usually a dollar sign ($). Do not type the prompt when you are following the instructions; you only want what follows the prompt.

Installing Git on Windows

  1. Download the latest version of Git for your operating system by going to
  2. Run the installer. For Windows, you can accept the defaults as they are all reasonable. On the "Adjusting your PATH environment" screen choose "Run Git from the Windows command prompt.")
  3. To confirm Git has installed correctly, open a terminal window and at the prompt, type 'git' (without the quotes). A list of the most common Git commands will print to the screen.

Installing Git on Mac
You can choose one of the following three options. The Git installer does not require any additional third-party software.

  • Using a installer dowloaded from
  • Using homebrew on Mac:
    $ brew install git bash-completion
  • Using Macports on Mac:
    $ sudo port install git-core +bash_completion +doc +gitweb +svn

Installing Git on Linux
You can find more instructions for your particular distribution at

  1. On RPM-based systems (RHEL, Fedora Core, CentOS, ...), open Terminal and type:
  2. $ sudo yum install git

  3. On apt-based systems (Debian, Ubuntu, ...), open Terminal and type:
  4. $ sudo apt-get install git-core

Moving Around on the command line
These are some commonly used commands for moving around from the command line. You should try these out and get familiar with at least these basics so you can use Git effectively from the command line.

  • pwd (present working directory)
  • ls (list) for information
  • cd (change directory). For example, if you are already in a Drupal root directory, type the following to move to your modules and then themes directories (using .. before a path moves up one directory):
  • $ cd modules
    $ cd ../themes

  • CTRL + C will cancel an action.

Basic Configuration
These next commands are a simple way to update Git's configuration file, .gitconfig. The file is a hidden file that normally lives in your user home directory (e.g. on a Mac, this would be in /Users/myusername/.gitconfig). When you run these commands you won't see any response in the terminal, but your .gitconfig file will be updated.

  1. Tell Git who you are. Use whatever name you would like to have publicly associated with your commits. Note that if your name has a space in it, you have to put the quotes around it.
    $ git config --global "Your Name"
  2. Provide your email address where anyone with questions about your commits can contact you.
    $ git config --global
  3. Set Git to use automatic line endings.
    $ git config --global core.autocrlf true

Download Drupal Using Git
For higher rungs on the Drupal Ladder, you will want to have a Git repository for Drupal core. You can find the correct Git information for Drupal core in the same way as for projects ( Doing the simple clone command below will download the cutting edge version of Drupal, sometimes referred to as HEAD, which is currently the Drupal 8 development version. Again, this code will be downloaded to the location you are in on the command line, so typically you will download this in the web root folder of your local web server.

git clone

Once you have a Drupal 8 clone, you should always update it to the lastest code before you start new work. You can pull down all of the latest changes from, by moving into your Drupal 8 directory, make sure you are in the "8.0.x" branch with git checkout 8.0.x and then doing a git pull command:

git pull

Download a Project Using Git
Now you can start to use Git to download, or clone, code from First we'll download a module. You will download the code directly to where you run the command from. For a module, you would typically download it into the proper place within a Drupal site, e.g. drupalroot/modules, so you would want to first cd to that directory and then proceed with a git clone command.

  1. Move into the correct directory for your project, e.g. cd modules from your Drupal root.
  2. Find a project on (for example, Admin Toolbar). On the project page, click the "Version control" tab (near the top of the page).

    Admin Toolbar Version Control tab
  3. Select a version of Drupal from the drop-down list that matches your Drupal site version.
  4. Copy the git clone and cd commands listed there. Paste them into your terminal window. (If you are using Git Bash on Windows, you can click the icon on the upper left corner of the application window to get a menu, where you can select Paste, or you can use the shift+insert keyboard shortcut.)
  5. Once the clone is complete, try these informational commands:
    $ ls -a
    $ git status
    (view the status of your files in the working directory and staging area)
    $ git branch -a
    (list, create and manage working contexts. The option -a shows both existing and remote tracking branches)
    $ git log -3
    (shows commit logs. The -3 option limits to the latest 3 commits.)


A suggested edit:
>Find a project on (for example, Admin Menu). On the project page, click the "Version control" tab (near the top of the page).

Find a project on (for example, Admin Menu). On the project page, click the "Version control" tab (under the project's name).

Probably just me, but I couldn't find the "Version control" tab for the longest time. d'oh!

Suggested edits under the "Basic Configuration" heading:/u
Use the same instructions as found on

Locate the .gitconfig file for your user account:

  • On Unix-like systems (OS X, Linux, BSD), check ~/.gitconfig
  • On Windows, check C:\Users\[username]\.gitconfig

Suggested edits under "Download a Project Using Git" heading:

... (e.g. for Drupal7 core modules, drupal7root/modules; for Drupal8 core modules, drupal8root/core/modules) ...

Suggested edits under "Download a Project Using Git," add to the last line in item #5:

(shows commit logs. The -3 option limits to the latest 3 commits. Type 'q' to exit the log display.)

Finally, I have a question instructions under "Download Drupal Using Git" where it states:

..., so typically you will download this in the web root folder of your local web server.

This sounds as if my local git clone of the Drupal8 repository will live in location separate from the Drupal8 distribution I've installed in my Acquia Dev Desktop? Is this true?

Update status: 
Needs revision