I have a web application built in PHP. I want to use Git to manage the different aspects of the deployment.

Some of the files in the web app are specific to a client (logos, database connection string, user uploaded files (ckfinder), etc. The rest is the same for everyone.

The application is heavy so I'm afraid to make it a Saas. Instead each client has his own vps. I used to have (in the past) a branch for dev a branch for production and so on.

So I was thinking to have a branch for each client. Is this a good idea? Also I wanted to have in my local machine a different folder containing files for each client (including the common files).

PS: I reviewed many other questions and all the others questions are very similar but the answers are not what I'm looking for.


Having a branch per customer is not an ideal solution, for a couple of reasons:

  1. It doesn't scale well. You will have to create a new branch for each customer, and then manage merging code changes between all those branches. And, when you actually do need a branch for a legitimate reason (feature branch, production fix, etc.), you'll have to branch all those customer branches! Too complicated.

  2. Logically, creating customer branches in most cases mixes up the roles of the source control system and your deployment or product management mechanisms.

A better solution would be to segregate all the possible files that are different per-customer. E.g., create a resources directory, with sub-directories for each customer containing their respective logos, connection string files, etc. Then, look into deployment tools such as Puppet, Chef, Ansible, etc. and create scripts to copy each customer's resources into their web server location when you're ready to update their site.

This way, resources are physically separated, and your processes are logically separated (source stays in Git, deployment practice is codified in script(s)) so you have artifacts representing your production pipeline.


  • thanks for your answer. can u suggest a deployment tool that do that? I mean that can deploy a software excluding some parts according to the server I deploy in...? I managed to have a folder called brands and within it a folder for each client containing the custom files. for example /brands/client1/settings.php and /brands/client2/settings.php.
    – Aslabs
    Oct 15 '14 at 9:58
  • @Aslabs I mentioned a few tools in my response, but you can always start with basic shell scripts to get the workflow defined, and then integrate into a smoother process later on. CI systems like Bamboo, TeamCity, etc. offer script integration into their deployments.
    – Dan1701
    Oct 16 '14 at 3:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.