May 29, 2015 - Brian Moore

GitHub and Acquia: How to best manage branching and pull request

Code reviews are an essential process to ensure a high quality of code. When working with Git projects, GitHub has created an excellent way to handle quick code reviews with Git via Pull Requests. On GitHub, this creates a comment forum, and an easy to read review of the changes. Think Git’s request-pull, but prettier and easier. Since we started using GitHub's Pull Request functionality, we developers have appreciated the immediate feedback on their code, and have the peace of mind knowing our has been reviewed.

The method for a pull request is relatively simple. Feature code being written should be put into its own feature branch. When that branch is ready to be merged into the master (or other production) branch, then a pull request is made. Within a few minutes, a reviewer can look at the code and the diff, and review that there aren’t any logic or style errors in the code (this is an excellent time as a reviewer to ensure that new functionality is documented appropriately). Once the reviewer is satisfied with the quality of the code (and all merge conflicts are taken care of) then they can process the merge.

Acquia uses Git, branching, and tagging to handle the code being deployed to the servers. This is a big win for choosing Acquia as a hosting provider, as you don't have to muck around with CI servers and integrating with Git. Unfortunately, they don't have the beautiful interface that is GitHub (including their Pull Request functionality). But not to worry, you can still use GitHub as your main code repository, and use the branching and pull request functionality that keeps your code as sharp as ever, and still push to Acquia to build appropriately.

The steps are simple enough. Firstly have your GitHub repository cloned where you want it locally.

 

git clone git@github.com:my/site.git

 

Then you will want to add your Acquia remote (using your Acquia Git URL).

 

cd site

 

git remote add acquia site@devcloud.hosting.acquia.com:site.git

 

And make sure you have it set up correctly.

 

git remote -v

 

origin git@github.com:my/site.git (fetch)
origin git@github.com:my/site.git (push)
acquia site@devcloud.hosting.acquia.com (fetch)
acquia site@devcloud.hosting.acquia.com (pull)

 

Now whenever you want to push to Acquia, you can do the following:

 

git push acquia master

 

And you can do this with branches and tags. Simple enough, allowing you to use GitHub's tools, and Acquia's hosting. Best of both worlds.

Bonus: If you want to automate things, you can use GitHub's hooks to push the appropriate events to a server used to mirror the repositories, or you could set up a cron job to regularly mirror the changes. We'll be automating things on Heroku, so you can look forward to a future blog post!

WorkCapabilitiesInsightsAboutCareersContactLegalPartners