Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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
add comment

1 Answer

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
add comment

Your Answer

 
discard

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.