Documentation Level: 
Intermediate
Documentation Status: 
No known problems

The best workflow for a perfect Git status

If your workflow demands that the result of git stauts is always Your branch is up-to-date then this might be the your choice for how to manage configuration files.

Configuration directory set-up

config/
config/active
config/staging
config/versioned <-- track via Git

Additional set up

  1. Move config outside of files (and preferably outside the docroot)
  2. Update settings.php to point at the new locations of active & staging

Development site settings.php example:

/**
* Site configuration files location.
*/
$config_directories['active'] = '../config/active';
$config_directories['staging'] = '../config/staging';

Production site settings.php example:

/**
* Site configuration files location.
*/
$config_directories['active'] = '../config/active';
$config_directories['staging'] = '../config/staging';

Deploying to prod - moving upstream

  1. local: Manually delete all files in the versioned directory.
  2. local: Manually copy the all the files from the active directory into the versioned directory.
  3. local: git add & git commit all files in staging.
  4. local: git push to get all files into the Git repository.
  5. production: git pull to pull all config changes onto the production server.
  6. production: Manually copy the all the files from the versioned directory into the staging directory.
  7. production: Run the config importer (via Backdrop UI).

When you git pull on the production server, the staging directory is unchanged. The config files must be manually copied from the versioned directory before they will be ready for import via the Backdrop UI.

Sync local to prod - moving downstream

  1. production: Manually delete all files in the versioned directory.
  2. production: Manually copy the all the files from the active directory into the versioned directory.
  3. production: git add & git commit all files in staging.
  4. production: git push to get all files into the Git repository.
  5. local: git pull to pull all config changes onto the production server.
  6. local: Manually copy the all the files from the versioned directory into the staging directory.
  7. local: Run the config importer (via Backdrop UI).

Upsides:

  • All files tracked via Git will remain "up to date" after importing staged config

Downsides:

  • Manual copying of directories required for every deployment.
  • Accidental reverts are possible (due to manual copy) - see (1) below
  • Extra steps are added to deployment (due to manual copy)

(1) ACCIDENTAL REVERTS ARE POSSIBLE: If there was ever a config change made on production and not actively copied out of the active directory and committed wherever it's supposed to be tracked, the next time code is deployed that production change would be reverted.