gitmodulecode-organizationproject-organization

Git submodule or sub-repository or remote?


I'm using GIT to manage a Content Management System (CMS) project. The CMS can have multiple plugin (module).

So basically, I want to have 3 types of repositories:

For the type 1 & 2, I guess it's simple basic repository. But when it come to client project, I get confused:

So the question is: How should I organize the repository(s) / files / folders in order to be efficient ?


Solution

  • The layout you've described will work really well with git submodules. I'd gently recommend reading the docs and trying a few tutorials. The key difference your plan introduces is that each client repository and client plugin repository will have two remotes instead of one. And, when you want to start a new client project you will need to

    1. fork the mainline cms
    2. fork all of the plugins that will be modified
    3. clone the forked cms from (1), update its submodules to point to the new remotes from (2)
    4. initialize/update the submodules
    5. (optional) add the mainline cms URL as a remote in your client's forked cms
    6. (optional) add the mainline plugin URLs as remotes in your client's forked plugins

    A better option may be to use the same repository and simply make a branch per client. That is how I would do it.