INTEREST JOURNAL DRUPAL & WEB

Drupal Guide in Detail: 11.11 Managing Code and Configuration with Git

About 400 words 2 min read

Japanese ↗
On this page

Detailed guide. An unofficial adaptation of User Guide 11.11. Source updated April 14, 2025; reviewed November 6, 2026. No running-Drupal procedure test has been performed.

Official source ↗ · Previous: 11.10 Synchronizing Configuration Versions · Chapter 11 overview

Goal and prerequisites

Track code and exported configuration with Git. Prepare Git, terminal access, a repository and its URL. Git does not automatically back up database content, accounts or uploads.

Workflow and our qualifications

Identify the project top and document root. In a Composer layout, composer.json and lock sit above web. Exclude credentials and uploads with appropriate .gitignore paths. The source excludes settings files, upload directories and config; adapt web prefixes and ensure the intended configuration export directory is not also ignored.

For a new repository, initialize, inspect, stage, commit and connect its remote. Do not repeat initialization or remote setup for an existing project. Our selective staging example replaces the source’s broad git add -A:

git status
git diff
git add composer.json composer.lock
git diff --cached
git commit -m "Record dependency changes"
git push

Use the actual branch, not an assumed master. Clone new copies; update existing ones with attention to local changes and conflicts.

Track exported configuration

Export as in 11.10 , unpack outside the public root into a tracked directory, and repeat there when configuration changes. Compare deletions as well as additions. Importing configuration into another environment remains a separate operation.

Our verification examples

.gitignore does not erase already tracked secrets. Inspect staged files and destination before pushing; keep dumps, credentials and uploads out. Maintain separate database/file backups. No repository initialization, commit or push occurred here.

Sources, credits and changes

Source: Drupal User Guide 11.11 ↗ . Contributors and source links listed in its Attributions: Jennifer Hodgdon ↗ · “Building a Drupal site with Git” ↗ · Drupal Community Documentation ↗ . Refer to the source for writing, editing and adaptation roles, and to the guide-wide credits ↗ .

Copyright remains with the individual contributors; the official copyright page ↗ states © 2015–2025. Changes include reorganized explanations and procedures, our preparation and verification examples, troubleshooting notes, source-interpretation qualifications and release references. Original screenshots and videos are not reproduced. This adapted text is shared under CC BY-SA 2.0 . It is not an official edition or endorsement. This notice does not license unrelated articles or the site design.

Previous: 11.10 Synchronizing Configuration Versions · Chapter 11 overview

Chapter 10 details · Chapter 12 · All chapters · Search official information

Back to chapter contents ↗