3

We are creating several websites, the main content will be the same across each of them but there will be some differences (e.g. extra button, extra texts, different styling)

what is the best way to manage this in git. there will end up being around 30 sites and we want a way to be able to easily change something across all of them if required.

my first thought was git branches?

Jason
  • 51
  • 2
  • 1
    You might want to search further, looking for discussions on "branches versus features", "feature toggles", and similar terms. This is an old problem. – BobDalgleish Dec 05 '18 at 21:15
  • @BobDalgleish Would be nice to have link to existing related discussion if this is old-duplicate problem. – Tomas Kulhanek Dec 05 '18 at 23:15
  • 1
    Could be that: https://en.wikipedia.org/wiki/Feature_toggle. "[Feature Toggle] should be your last choice when you're dealing with putting features into production" as suggested by Martin Fowler on that site can be a starting point to find alternatives. – User Dec 06 '18 at 00:20
  • Also, the side-bar suggests promising related work: https://softwareengineering.stackexchange.com/questions/197854/working-with-multiple-versions-of-websites-git?rq=1 – User Dec 06 '18 at 00:23
  • 1
    Possible duplicate of [Maintain hundreds of customized branches over master branch](https://softwareengineering.stackexchange.com/questions/302147/maintain-hundreds-of-customized-branches-over-master-branch) – Doc Brown Dec 06 '18 at 11:44
  • .. see also [Source/Version control for application used by multiple companies](https://softwareengineering.stackexchange.com/questions/133485/source-version-control-for-application-used-by-multiple-companies) – Doc Brown Dec 06 '18 at 11:45
  • 1
    Possible duplicate of [Source/Version control for application used by multiple companies](https://softwareengineering.stackexchange.com/questions/133485/source-version-control-for-application-used-by-multiple-companies) – Bart van Ingen Schenau Dec 13 '18 at 13:25

1 Answers1

0
  1. Using git branches, as you mentioned.

Of course you can create some kind of 'main' branch for your prototype and each branch for specific page.

Your process will be then:

  • git checkout -B new_branch to create a 'copy' of template.
  • Commiting some changes to your new branch.
  • In meanwhile, making some updates to your 'mainline'.
  • git merge main_branch to reapply updates on each specific branch.

What could be the problem: After some time the differences between 'mainline' and each specific branch will grow up to the point that you realize, that you spend most of your time by resolving merge conflicts than real development.

  1. Better solution, using your target technology.

In my humble opinion, better solution would be to develop your common functionalities as some kind of 'library' or 'template'. Then include or import it in your specific projects.

How to do it, depends mainly on your technology. You can do it using some kind of full feature modern framework like Angular, React or Vue. It can also be some simple set of Javascript functions that operate on DOM.

Remember, that you have two possibilities (you have to decide which will bring you more advantages in your case):

  • Create a template with some kind of 'entry points' that make it easy to change behavior in sub-projects.
  • Create a set of reusable components.
mpasko256
  • 336
  • 1
  • 3
  • 10