user1848605
user1848605

Reputation: 747

How do I manage two very similar websites with single Git repository?

I have a website that exists in two versions - language versions. They run on different server as different websites, mostly differ only in text and some configuration images etc. but it can be expected that they will differ with functionality in the future as well.

Since both the websites have the exact underlying functionality so far (but may differ in the future), I want to be able to

A) Do changes to both of them simultaniously. B) Do changes to only the first version of the website. C) Do changes to only the second version of the website.

Now what is the best approach to do this? I chose git branches - I have a MASTER branch and then branch A and branch B. If I want to do changes to both websites, I do them on MASTER and then merge MASTER into both A and B. If I want to do seperate changes on A, I do them only there.

Is my workflow so far correct? What is a better approach? I'm asking this because I did some merging wrong and reversed few commits and now the project is a mess. There has to be a better solution.

Upvotes: 1

Views: 226

Answers (1)

Max Yankov
Max Yankov

Reputation: 13327

You can:

  • Keep all the data in one branch, and let the special configuration file, included in .gitignore, decide which site is it.
  • Keep common code in a "master" repository, and different content in two other repositories that reference this repo as a submodule.
  • Move all configuration and content into databases specific for each deploy location.
  • Continue working as you are now.

I don't think that there's an ideal option, however. I have some personal experience with such a situation, although it's different from yours — I work on compiled project. We have iPhone build, iPad build, etc, and use the first approach. We keep all the code in one repo and one branch (well, we use branches, but for other needs). We have a special tool that changes the project configuration target; however, all the files are kept in the repo, and if someone changes the build target and commits all the changes, it affects all of us. However, since changing the build takes about 20-40 seconds, it's not an inconvenience.

Upvotes: 2

Related Questions