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?

closed as too broad by gnat, BobDalgleish, Doc Brown, Jörg W Mittag, Bart van Ingen Schenau Dec 13 '18 at 13:25

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  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.

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