Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best practice for using git on multiple projects with the same base?

Tags:

git

I had a project running on a client which using git as its version control.
After a while, another client wanted the same project with some different features.

Then, I thought of 2 options to manage the new one in git repository.

One, fork the repository, or two, make another branch specific for the new repository.

Since I was new to git, I did both of those to test which was easier to maintain. I, later, went with option two, since it was a lot easier to fix errors in a client then cherry-picked it to another branch (if the errors were in the features that were used in another clients). And also it seems to be easier to switch branch in IDE than have several projects.

However, I am still not convinced that this is the best practice for a several projects since now I have more clients (thus, more branches).

It is really confusing to use branch per feature, and I want to utilize the pull request feature of git. I start to think that it is better to separate projects in their personal repositories.
But if I do that, can I still using a single project in my IDE?

How can I "push" the error fixes to another repository without having to re-code (literally code again, copy paste, or using diff) them in another projects?

Am I doing the right thing?
Or is there a better way to do this?

Thank you in advance.

like image 946
Iqbal Djulfri Avatar asked Feb 11 '16 04:02

Iqbal Djulfri


1 Answers

Version control is not the answer to this, this is not a problem it was never meant to solve. You should have a single codebase for all of your clients, and you should build your features in such a way that they can be turned on and off within that codebase.

Whether that means distilling features out to loadable modules, or building them such that your code is littered with if/else statements is up to you, but either solution is better than an explosion of divergent branches. The branch-per-client solution is barely better than just copying and pasting the entire codebase to a new directory for each client. If you wind up with a hundred clients and a hundred divergent branches needing to be independently maintained, you're no better off because of version control.

like image 111
meagar Avatar answered Nov 11 '22 01:11

meagar