Combine a base project that is growing in child projects in git repository except git submodule or subtree merge methods

There are some child projects: “Project 1”, “project 2” and so on in the future.

Also, There is a project that named: “Base Project” and it’s foundation of other projects. “Base Project” is a content management system (CMS).

All projects have their own git repositories.

“Project 1” , “project 2” and others uses “Base Project” to develop and grow.

There are some methods in git like submodule or subtreemerge. but don’t seem to fit here.
“Base Project” not should be clone into a sub directory. It’s in root directory. It’s growing in “project 1” or “project 2″…

When I work in child projects, I have to be able to push “Base Project” changes separately to It’s own repository to fetch in other children.

What can I do?

  • Self-host remote git repository on Windows server
  • git fetch and subsequent merge does not do the same as git pull - Why?
  • Using Git to separate code changes when working on more than one issue
  • If I'm using Atlassian Stash, can the git repo still be managed without using Stash?
  • Jenkins Build on push option is not appearing
  • Git push --all branches that are already on remote, but not un-published local branches
  • One Solution collect form web for “Combine a base project that is growing in child projects in git repository except git submodule or subtree merge methods”

    Subtree merge or submodules are for a component-based development: two different but coherent set of files combined together.
    Each set of files is in its own directory, because they can be branched or labelled independently (submodules), or together (subtree merge, while keeping the ability to get back an history of their own).
    Both are requiring a separate directory though.

    But what you are describing (“Base Project” is in root directory, growing in “project 1” or “project 2“) is about a system-based approach: all components merged into one large component: one large set of file which will always evolve together, as one unit.
    So you can have one branch per project: branch1 for CMS-projet1, branch2 for CMS-project2, and so on.

    But if you need to report projectx-specific modifications or CMS-specific modifications back to their original (and separate) repos, then make said specific changes in dedicated branches, and then combine those changes:

    • branchp1 would be for changes affecting project1
    • branchc1 would be for changes affecting CMS
    • branch1 would be the result of the merge from branchp1 and branchc1

    (same thing for branch2)

    You can then export those changes as patches:

    • from branchp1 to project1 repo
    • from branchc1 to CMS repo

    The inconvenient is that Git won’t remember what has already been merged back to the original repos, but that would allow you to report the common history developed in your CMS-projectx set of files back to your original CMS and projectx repos.


    Note: if you don’t want to manage 2 extra branches, another solution is to:

    • make sure each commit only include CMS modification OR project modification
    • leave a commit message which helps to distinguish them (“[CMS] my CMS modification comment...“, or “[Project1] my project1 modification comment...
    • use the script git-extract-patches to export as patches only the right commits.
    Git Baby is a git and github fan, let's start git clone.