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.

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:

  1. Setting up the Repo
  2. Adding the Site to the Repo
  3. Create the Pantheon Site
  4. Set Local Development Environment
  5. Pull in Pantheon's Upstream
  6. Add Pantheon Remote and Commit Code from Upstream
  7. Create the Develop Branch
  8. Set up Multidev
  9. Your First PR
  10. Syncing with Pantheon
  11. Deploying the PR for Test and QA
  12. Merging to Master (the other one)
  13. 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.

Requirements

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.