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 Git
Additional set up
- Move
config
outside 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
versioned
directory. - local: Manually copy the all the files from the
active
directory into theversioned
directory. - local:
git add
&git commit
all files inversioned
. - local:
git push
to get all files into the Git repository. - production:
git pull
to pull all config changes onto the production server. - production: Manually copy the all the files from the
versioned
directory into thestaging
directory. - 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
versioned
directory. - production: Manually copy the all the files from the
active
directory into theversioned
directory. - production:
git add
&git commit
all files inversioned
. - production:
git push
to get all files into the Git repository. - local:
git pull
to pull all config changes onto your local. - local: Manually copy the all the files from the
versioned
directory into thestaging
directory. - 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.