Information for: DEVELOPERS   PARTNERS

Using Git

Git is the version control system (VCS) available for use with Acquia Cloud. The following information will help you use Git to manage your Acquia Cloud code repository. For a video introduction, see Git Fundamentals for Acquia Cloud (sign-in required) at Acquia Academy.

Note

Acquia does not provide support for third-party version control management tools.

Downloading a Git client

You will need a Git client installed on your local system to work with your code repository.

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

Note

Ensure you enable SSH access to your Acquia Cloud environments.

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 Acquia Cloud, and then select your application.

  2. Click Application info.

    Application Info icon to display the Application Information panel

The Application Information panel displays basic Git commands for your application 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 to copy a command to your clipboard and then paste the command into an SSH session.

You can also find procedures to help you start 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 name that describes the work the branch 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 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 must run a Drush command that only affects one of your websites, ensure you use the --uri=site.example.com parameter, where site.example.com is your website’s complete website 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 the release 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, and then switch to the new branch, using a command like the following.

      git checkout -b [release-candidate]
      
  2. Run the following command to ensure 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 like the following:

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

    git push origin [release-candidate]
    

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 Acquia cannot 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 Drupal.org
docroot/profile Custom profiles
docroot/themes  

Drupal 7

Drupal 7 expects code changes in the following directories:

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

Additional resources

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