Good use of git branching can definitely help with this. The key thing is that each individual branch has a stable configuration basis: nothing external to the branch should change the configuration state within the branch, so that later when it's time to export configuration in the branch and merge it into production, only the changes relevant to the branch are recorded.
One way to do this is to have a main branch called production
, and the HEAD of that branch always tracks with the current production state of your codebase. You all agree not to commit or merge things to production
unless you're preparing to release those things live.
When Arjun wants to work on a new feature, they make a new branch off of production
, and they call it arjun-1
.
The next day, Beth needs to fix a bug, so she makes her own new branch off production
called beth-1
.
Meanwhile, content manager Ceci is in the site UI building out webforms, which means she is making live configuration changes that diverge from the config state of production
. In a way, she too is branching off of production
! In fact, let's go ahead and create a ceci-1
branch off of production
now to represent this, even though we probably won't commit anything to it yet.
A few days later, Arjun and Beth's respective branches have been reviewed and accepted, and management wants to deploy a new release with their work to the live site.
The first thing to do is check out the ceci-1
branch, export the live configuration and commit the updated config files to ceci-1
.
Now you can proceed to merge to production
: the new feature arjun-1
, the bugfix beth-1
, and the live configuration updates ceci-1
. There may be merge conflicts to review, but you should not have to worry about accidentally overwriting someone else's config. This is because each individual branch had a consistent basis from which to export their own individual config changes.
Let's say you didn't make a ceci-1
branch. Instead, you merged arjun-1
and beth-1
into production
, then exported the live config and committed the live updates into production
. You have screwed up! You changed the basis for Ceci's live site configuration changes. They had been based on the state of production without Arjun and Beth's branches. Exporting now will overwrite any configuration changes they had made.