How can I get track of several projects in Git tha

2019-05-05 21:21发布

问题:

I have developed a website that now has to be cloned for several clients. Each client wants customizations that go beyond visual aspects and cannot be handled by profiles, preferences or something like that.

With this scenario, I would like to mantain a master repository in Git with the common code, and then one branch for each client. This way, I can make individual changes in every client (branch) and share common changes as well (using the master).

Is this approach correct? Is there any other way to handle this apart from remote branches?

Thanks!

回答1:

This will work.

You have to be careful with merges -- you can only merge from the common code to the client code, but you can cherry-pick individual changes back from clients to common. You'll also want to work out what your policy will be on bringing code from the common branch to the client branches -- if there's not too much client-branch code, you may be better off rebasing your client changes on top of the common code every time you want to update; with more changes it'd be a lot easier to merge the common code in.

If you go for the rebasing approach, take a look at git rerere, which is intended to help you deal with rebasing often.



回答2:

If your repository is structured such that all of the common-code lives in its own separate directory, it's possible to solve this using git-submodules.

If it's the case that, instead, all of the client-customizations live in their own subdirectory I think it's possible to use the subtree merge-strategy to solve this elegantly.



标签: git branch