Ajouter un commentaire

Using GitHub with Acquia Cloud

Most Drupal developers are moving towards Git, and many of them prefer to host their Git repos at GitHub for their excellent Git support, Pull Requests with integrated code review, and more. At Acquia, we think GitHub is terrific, too, and like to use it for many of our own public and private projects.

Many people have asked us whether it is possible to keep their site’s code in GitHub and still host it on Acquia Cloud. The answer is yes, and it’s pretty simple, too. The trick is to have two "remotes" for your local repo clone, one at GitHub and one at Acquia Cloud.

Suppose you have an existing repo at GitHub containing your site’s code. You make a local clone like this:

$ git clone git@github.com:me/mysite.git
$ cd mysite
$ git remote -v
origin    git@github.com:me/mysite.git (fetch)
origin    git@github.com:me/mysite.git (push)

GitHub is the "origin" remote, the default location for "git push" and "git pull". Now, you’d like to deploy this site to Acquia Cloud. You simply add your Acquia Cloud repo as an additional remote named something short, like "ac", and then do an initial "git push --force ac" to re-initialize the Cloud repo:

$ git remote add ac mysite@svn-18.devcloud.hosting.acquia.com:mysite.git
$ git remote -v
origin    git@github.com:me/mysite.git (fetch)
origin    git@github.com:me/mysite.git (push)
ac    mysite@svn-18.devcloud.hosting.acquia.com:mysite.git (fetch)
ac    mysite@svn-18.devcloud.hosting.acquia.com:mysite.git (push)
$ git push --force ac

Now you have two remotes, origin (GitHub) and ac (Acquia Cloud). You can edit some files and push them to GitHub:

$ vi somefile.php
$ git add somefile.php
$ git commit -m ‘edited somefile.php’
$ git push origin master

You can also push the same changes to Acquia Cloud:

$ git push ac master

Your new code is now in both your GitHub and Acquia Cloud repo, and is running on your Acquia Cloud site.

Suppose that now you deploy your code on Acquia Cloud from the Development environment (running the master branch) to Production. This creates a new "release tag" in your Acquia Cloud repo showing you exactly what code you released that day. You do not have to synchronize that release tag to GitHub, but you can:

$ git pull ac
From svn-18.devcloud.hosting.acquia.com:mysite
* [new tag]         2012-03-12 -> 2012-03-12
$ git push --tags

Now your GitHub repository contains the same release tag as your Acquia Cloud repo.

There is one other wrinkle you may need to address. Acquia Cloud requires that you keep all of your Drupal site code in the directory "docroot" in your repo. Your existing GitHub repo may not be set up that way, and you may have a lot of commit history in that repo that you want to preserve. No worries; you can use "git subtree" to translate your GitHub repo’s root directory into an Acquia Cloud "docroot" directory. That’s a subject for another blog post, but luckily Acquia’s Peter Wolanin has already written it; see Using git subtree to Make a Distro Your Docroot.

Try a free 30-day trial of Acquia Dev Cloud today!

Plain text

  • Aucune balise HTML autorisée.
  • Les adresses de pages web et de courriels sont transformées en liens automatiquement.
  • Les lignes et les paragraphes vont à la ligne automatiquement.

Filtered HTML

  • Use [acphone_sales], [acphone_sales_text], [acphone_support], [acphone_international], [acphone_devcloud], [acphone_extra1] and [acphone_extra2] as placeholders for Acquia phone numbers. Add class "acquia-phones-link" to wrapper element to make number a link.
  • Pour publier des morceaux de code, entourez-les avec les balises <code>...</code>. Pour du PHP, utilisez. <?php ... ?>, ce qui va colorier le code en fonction de sa syntaxe.
  • Les adresses de pages web et de courriels sont transformées en liens automatiquement.
  • Tags HTML autorisés : <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <h4> <h5> <h2> <img>
  • Les lignes et les paragraphes vont à la ligne automatiquement.
By submitting this form, you accept the Mollom privacy policy.