Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working in a couple of websites, both websites needs almost the same code except for some changes in images and css, or settings.

I'm just finished to read the chapter of branchs of Pro Git book and i'm a bit confused, if a branch is not the best solution for this problem, is a fork?

I mean, we have instances A and B of the code, between A and B, the differences are things likes css colors, urls, api keys, but most of the code is the same, so in what way I can deal with this, i need something like code in A and then 'patch' it to get B, but i'm not sure how make a merge that doesn't overrides images...

Anyway, if is a branch or a fork, how can I make a merge for new features in A without lost changes in B?

share|improve this question
up vote 3 down vote accepted

I don't think either branching or forking is going to solve the problem for you. I believe you need to approach this from a completely different angle.

The code that is shared between the sites is effectively a code library, and should therefore reside in a common library folder. In a LAMP environment, that would be /usr/share/php/. The individual sites then form projects of their own, with folders for CSS, JS, images, etc, and a few files that make use of the library code. If this is done intelligently, you probably only need an index.php file (and some rewrite rules).

Right now this probably sounds like a huge task, but I am pretty sure that branching or forking in git is not the way to approach this problem.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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