As a veteran web developer of nearly 20 years, one of the more difficult things I ran into when I started with Mediacurrent, a Drupal agency, was working within the constraints of a version control system. For most of my career I’ve worked directly on the servers, using subdomains and transitioning things to and from live by swapping hosts.
I have used version control for particular client projects in the past and for projects on Drupal.org, but it was never to the degree where its usage became second-nature. I’m still not ready to call myself totally fluent with Git, but I believe I have come a long way in the past 7 months. I wrote this Guide to Version Controlled Drupal Development Using Git, Bitbucket and Pantheon (PDF) to share what I've learned thus far.
13 Steps to Building a version controlled development environment
In this resource guide, I will introduce you to one of Mediacurrent’s common set ups for a development environment. For this example, we’re going to take an existing Drupal 7 site that is already live and build a development environment around it in thirteen steps:
- Setting up the Repo
- Adding the Site to the Repo
- Create the Pantheon Site
- Set Local Development Environment
- Pull in Pantheon's Upstream
- Add Pantheon Remote and Commit Code from Upstream
- Create the Develop Branch
- Set up Multidev
- Your First PR
- Syncing with Pantheon
- Deploying the PR for Test and QA
- Merging to Master (the other one)
- Sync the Master Branch with Bitbucket
We’ll create a Git workflow that will provide a solid development environment where developers can submit their work in the form of Pull Requests (PRs). The PRs can then be reviewed, commented upon and either rejected or approved. Work from approved PRs will then be merged with a development environment for confirmation and then deployed to a test environment for quality assurance. Once the work passes QA, it is then deployed to the live environment. If it's hosted outside of Pantheon, the codebase is updated on the remote host.
To get started, you'll need the following:
- A website hosted on a server with git available
- Bitbucket account (free is fine)
- Pantheon account (either paid or using a free “Pantheon for Agencies” account)
- A paid or agency account is required for the multidev feature needed to synchronize with a develop branch. (Further detail is covered in Part 7 of the guide).
- Local development machine with git available
I hope this resource serves as a practical guide to version control your dev environment. In future guides, we’ll go over tagging branches for release, hot fixes and more, building upon what we’ve started here.
Using "Workflow Tools" to Deploy your Content (and Code) | Blog
Why Git-Flow for My Team?| Blog
Git-Flow for Daily Use | Blog