There are lots of different approaches to managing Backdrop CMS configuration files in Git, but this one is my favorite. It works great for projects with multiple developers, and it can also be easily adapted for multiple deployment environments, as on Pantheon.
This versioned staging directory strategy has been adapted from a recommendation from @populist and @davidstrauss based on how the config
directory is being managed for Drupal 8/9/10 on Pantheon.
Configuration directory
config/
config/staging <-- track via Git
config/live-active <-- track via Git
config/dev-active <-- DO NOT TRACK
Additional set up
- Move
config
outside offiles
(and preferably outside the docroot) - Update
settings.php
to point at the new active & staging locations (different active directories for each site instance)
Deploying to prod - moving upstream
- local: overwrite
staging
directory withdev-active
-- deletions too! - local: add, commit, push
staging
(via Git) - production: pull changes (via Git)
- production: run config sync (via UI, drush, or bee)
Sync local from prod - moving downstream - option 1 (writable web server)
Option 1 is for a web-writable live-active
config directory, and one where you have the ability to add, commit, or push via Git.
- production: add, commit, push
live-active
(via Git) - production: overwrite
staging
directory withlive-active
-- deletions too! - production: add, commit, push
staging
(via Git) - local: pull changes (via Git)
- local: run config sync (via UI, drush, or bee)
Sync local from prod - moving downstream - option 2
Option 2 is for a non-writable live-active
config directory, or one where you do not have the ability to add, commit, or push via Git.
- production: export active directory (via UI)
- local: overwrite
staging
directory with export -- deletions too! - local: add, commit, push
staging
(via Git) - local: run config sync (via UI, drush, or bee)
Because the staging directory is always versioned and deployed, every enviornment
Note: this blog post was adapted from older documentation. It has been adapted fro experience, and updated to account for changes to Backdrop core.