Handling one code base for multiple clients, with their own custom code

githubversion control

I am working on a CMS, in which we have multiple clients that use it, so the code is stored on their servers. Each client has the default code (user manager, pages manager etc), but every client also has it's own set of code (themes, scripts, custom modules).

I am trying to figure out a way to maintain an up-to-date code base for all the clients without having to make every single change to the core to every single client.

We are using GitHub for version control, so I was think of having all the clients as different branches, but how can I keep the core up to date with the master?

Am I think about this all wrong?

What are my options?

Best Answer

Branches are the wrong solution here. Branches are for when the code (temporarily) needs to change from the common base.

The problem with branches is that changes made to one branch stay on that one branch until you explicitly merge them onto another branch. This effectively means that if you have a change in the common code, you need to apply that change to each 'client-branch' individually, which is exactly what you don't want.

I am not fully up to date with git terminology, but the better solution is to have several repositories/sub-modules. You then create one repository for each client and an extra repository for the common code. The client's repository can then include the common repository as an external reference or sub-module and any change made to the common code is then immediately available to all clients repositories without additional work.