Using Git

Git is the version control system available for use with Acquia Cloud. Use the following information to help you use Git to manage your Acquia Cloud code repository.

Downloading a Git client

You will need a Git client installed on your local system in order to interact with the code repository using Git.

To download a Git client, use the method based on your operating system:

Basic Git commands

You can find several basic Git commands, customized for your Acquia Cloud application, in the Acquia Cloud interface:

  1. Sign in to the Acquia Cloud interface, and then select your application.
  2. Click Application info.

    Application Info icon

The Application Information panel displays basic Git commands for your application that you can use to clone a repository, stage modified files, commit changes, and push local commits to a remote repository. You can click the copy icon Copy icon to copy a command to your clipboard and then paste it into an SSH session.

You can also find procedures to help you get started with Git in Checking out a local copy of your code and Sending updates to your code repository.

Git best practices

The following best practices apply to any application hosted in Acquia Cloud, and can assist you in developing with Git:

Creating a feature branch

To create a branch for development work, complete the following steps:

  1. Open a command prompt window, and then change the directory to the location that contains the clone of your code repository.
  2. Switch to the master branch.

    git checkout master
    git pull origin master
  3. Create the feature branch with a descriptive name that relates to the code that it contains, and then switch to the new branch using the following commands, replacing [feature_id] with the name of your feature branch:

    git checkout -b [feature_id]
    git push origin [feature_id]

Create and use as many feature branches as needed to keep your development efforts separate from one another.

Committing branch changes

Whenever you want to commit your changes back to the code repository for the branch that you're working on, run the following command to commit the change locally:

git commit -a -m "Comment"

After you commit the change, send the change to the code repository (where [feature_id] is the name of your feature branch):

git pull origin [feature_id]
git push origin [feature_id]

When working with your code, if you need to run a Drush command that only affects one of your websites, be sure to use the parameter, where is your website's complete site and domain name.

Merging your feature branches

To merge your feature branches into a single release branch for testing, complete the following steps:

  1. Create a release branch from your master branch. You will use this branch for feature integration and testing. Use the following steps to create the branch:
    1. Switch to the master branch.

      git checkout master
      git pull origin master
    2. Create the release branch (in this example, the release branch is named RC), and then switch to the new branch.

      git checkout -b RC
  2. Run the following command to ensure that you have the most recent feature branch versions:

    git fetch all
  3. Merge each of the completed feature branches into your new release branch, using a command similar to the following:

    git merge [feature_id] --no-ff
  4. Push your release branch to the remote repository for testing.

    git push origin RC

Code placement in Drupal

As you develop each code branch, place code changes and additions in the folders appropriate for your version of Drupal. Placing your changes in other folders can cause serious problems for your repository, including merge conflicts that Acquia will not be able to help you resolve.

Drupal 8

Drupal 8 expects code changes in the following directories:

Directory Suggested contents
docroot/libraries Third-party libraries, such as WYSIWYG editors
docroot/modules/custom Custom modules
docroot/modules/contrib Modules from
docroot/profile Custom profiles

Drupal 7

Drupal 7 expects code changes in the following directories:

Directory Suggested contents
docroot/sites/all/modules/custom Custom modules
docroot/sites/all/modules/contrib Modules from
docroot/sites/all/libraries Third-party libraries, such as WYSIWYG editors
docroot/profiles Custom profiles

Additional resources

For more information about how to use Git, see the following online resources:

Contact supportStill need assistance? Contact Acquia Support