The best workflow for a perfect Git status
If your workflow demands that the result of git status 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 GitAdditional set up
- Move
configoutside of files (and preferably outside the docroot) - 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
- local: Manually delete all files in the
versioneddirectory. - local: Manually copy the all the files from the
activedirectory into theversioneddirectory. - local:
git add&git commitall files inversioned. - local:
git pushto get all files into the Git repository. - production:
git pullto pull all config changes onto the production server. - production: Manually copy the all the files from the
versioneddirectory into thestagingdirectory. - 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
- production: Manually delete all files in the
versioneddirectory. - production: Manually copy the all the files from the
activedirectory into theversioneddirectory. - production:
git add&git commitall files inversioned. - production:
git pushto get all files into the Git repository. - local:
git pullto pull all config changes onto your local. - local: Manually copy the all the files from the
versioneddirectory into thestagingdirectory. - 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.