Module 1.3 – Git and Version Control in Drupal

This module validates whether a Drupal developer understands how version control is used in real Drupal projects, especially in team environments and deployment workflows.

Acquia is not testing advanced Git internals. It is testing whether you understand safe, repeatable, and professional Git practices that support Drupal configuration management, deployments, and collaboration.


1. Git is mandatory in modern Drupal development

Drupal projects are expected to be managed using Git.

Git is used to:

  • Track code changes
  • Collaborate with teams
  • Deploy changes safely
  • Roll back mistakes

If an exam question suggests working directly on production without Git, that option is incorrect.


2. Typical Drupal Git repository structure

A standard Drupal Git repository usually includes:

  • custom modules
  • custom themes
  • configuration exports
  • composer files

It usually excludes:

  • vendor directory
  • contributed modules (when using Composer)
  • generated files
  • local settings

Understanding what belongs in Git and what does not is critical for the exam.


3. Git ignore in Drupal projects

The gitignore file defines which files should never be committed.

Common Drupal gitignore entries

/vendor/
/web/sites/default/files/
/web/sites/*/files/
/web/sites/default/settings.local.php
/web/sites/default/services.local.yml

Why this matters:

  • Prevents committing generated files
  • Protects environment specific settings
  • Keeps repositories clean

Exam insight: Configuration exports should be committed. Runtime files should not.


4. Branching strategy in Drupal projects

Most Drupal teams use a simple branching model.

Common branches:

  • main or master for stable code
  • develop for active development
  • feature branches for individual work

Example feature branch:

feature/safe-and-sound-map-fix

Feature branches allow isolated development without impacting shared code.


5. Merge and merge conflicts

Merge

A merge combines changes from one branch into another.

Example:

git checkout develop
git merge feature/my-feature

Merge conflict

A merge conflict occurs when Git cannot automatically resolve differences.

Typical Drupal conflict areas:

  • configuration files
  • routing files
  • same PHP file modified by multiple developers

Conflict resolution requires:

  • Understanding the code
  • Choosing the correct changes
  • Testing after resolution

Exam insight: Resolving conflicts locally before pushing is expected.


6. Cherry-pick in Drupal workflows

Cherry-pick applies a specific commit from one branch to another.

Example use case:

  • A hotfix committed to develop
  • Needs to be applied to main without merging all changes

Example command:

git cherry-pick <commit-hash>

Cherry-pick is common in production hotfix scenarios.

Exam insight: Cherry-pick is safer than merging an entire branch for a single fix.


7. Tags and releases in deployment

Git tags are used to mark release points.

Example:

git tag v1.2.0
git push origin v1.2.0

Tags are commonly used to:

  • Identify deployed versions
  • Roll back to a known release
  • Track production deployments

Acquia exam questions often associate tags with deployment stability.


8. Configuration management and Git

Drupal configuration management relies on Git.

Typical workflow:

  • Export configuration
  • Commit configuration files
  • Deploy code
  • Import configuration on target environment

Configuration files are part of version control and should never be edited directly on production.


9. User config and environment specific settings

Environment specific configuration should not be committed.

Examples:

  • database credentials
  • API keys
  • local overrides

These belong in:

  • settings.local.php
  • environment variables

Git ensures sensitive data is not shared across environments.


10. SSH and Git authentication

Most professional Drupal projects use SSH for Git authentication.

Why SSH is preferred

  • More secure than password authentication
  • Required by most Git hosting platforms
  • Enables automated deployments

Basic SSH workflow

  • Generate SSH key
  • Add public key to Git provider
  • Use SSH clone URLs

SSH setup is not deeply tested, but understanding its purpose is expected.


11. Common Git mistakes in Drupal projects

  • Committing vendor directory
  • Editing configuration on production
  • Working directly on main branch
  • Ignoring merge conflicts

These patterns are often used as incorrect answers in the exam.


Key exam takeaways

  • Git is required for professional Drupal development
  • Configuration belongs in Git, runtime files do not
  • Feature branches support safe collaboration
  • Cherry-pick is used for targeted fixes
  • Tags represent stable deployment points

Practice check

  • How do you apply a single fix to production: cherry-pick
  • What should never be committed: runtime files and secrets
  • How do you mark a release: Git tag
  • Where should configuration live: in Git