(Contributor) Clone the Magento repository

Totally lost? Need a helping hand? Try our installation quick reference (tutorial) or installation roadmap (reference).

Intended audience

The audience for this topic is anyone who contributes to the Magento Open Source codebase. You should be highly technical, understand Composer and Git commands, and be able to upgrade the Magento system software and extensions using those commands. If that isn’t you, go back and choose another starting point.

If you clone the Magento 2 GitHub repository, you cannot use the Magento software in a production environment. You cannot have a live store that accepts orders and so on.


Before you continue, make sure you’ve done all of the following:

Composer and Magento

We use Composer for dependency management. Composer enables us to manage the Magento components and their dependencies.

As an integrator, you want to manage each of your Magento core components and third-party components using the Component Manager and System Upgrade.

To do so, you start by creating a Composer project from our metapackage. The metapackage installs each component so it can be centrally managed after installation.

Composer provides you with the following advantages:

  • Enables you to reuse third-party libraries without bundling them with source code
  • Component-based architecture with robust dependency management
  • Manages dependencies to reduce extension conflicts and compatibility issues
  • Versioned dependencies
  • Semantic versioning
  • Supports the PHP Framework Interoperability standard

Install Composer

First, check if Composer is already installed:

In a command prompt, enter any of the following commands:

  • composer --help
  • composer list --help

If command help displays, Composer is already installed.

If an error displays, use the following steps to install Composer.

To install Composer:

  1. Change to or create an empty directory on your Magento server.

  2. Enter the following commands:

    curl -sS https://getcomposer.org/installer | php
    mv composer.phar /usr/local/bin/composer

    For additional installation options, see the Composer installation documentation.

Clone the Magento repository

This section discusses how to get current code by cloning Magento’s GitHub repository and checking out branches. You can either checkout a release branch or a development branch:

  • Release branches, like 2.1.0, are more stable. You must use a release branch with the Data Migration Tool.

  • Development branches, like 2.2-develop, contain the latest changes.

Currently, the 2.2-develop branch is the default, but you can checkout a release branch, like 2.1.0, after cloning.

Refer to GitHub’s documentation for instructions on cloning a repository.

Creating an authorization file

The Magento 2 GitHub repository requires you to authenticate. The composer install commands fails if you do not. To authenticate, generate authentication keys, after which you create an auth.json file in the home directory of the Magento file system owner .

Create auth.json

To create auth.json:

  1. Log in to your Magento server as, or switch to, the Magento file system owner.
  2. Edit or create auth.json in the user’s home directory.

    The following example shows how to add repo.magento.com authentication to an existing file:

       "github-oauth": {
         "github.com": "<your github oauth id>"
       "http-basic": {
          "repo.magento.com": {
             "username": "<public key>",
             "password": "<private key>"
    For example, if your username is magento_user, create or edit /home/magento_user/.composer/auth.json

Next step

After completing the tasks discussed on this page, see Update installation dependencies.