Chapter 10. Getting Started with Git

The reasons for using version control on your Drupal projects are several and various, and have only recently become clear to me, as I’ve started working with Drush and Git. Although adding version control to your workflow can be daunting at first, the benefits far outweigh the initial annoyances. Consider this:

  • In a recent project, while attempting to theme complex navigation on a Drupal 7 prototype, I found myself messing things up in a bad, bad way, less than an hour before major stakeholders were supposed to look at the site. Because we were using Git, I was able to roll back to the former, not-messed-up menu while we focused on other priorities—without having to make a frantic phone call to our developer.

  • When working with more than one person, version control allows you not only to figure out who made what changes to the code, but also to work on the same file at once without accidentally overwriting each other’s changes.

  • Finally, version control ensures that you have exactly the same files installed in all locations. This means you never have to worry that your local site is on a different version of a module than your server copy.

In this chapter we’ll install Git in our local development environment, set up a local and remote repository for a basic Drupal implementation, and learn how to work Git into our Drupal workflow.

Master Versus Origin

Git allows multiple development tracks to be going on simultaneously, using a technique called branching ...

Get Drupal for Designers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.