user2868835
user2868835

Reputation: 1600

Can a Git repo act as a child/inherit from another Git repo?

Git newbie question...

I have a situation where I want to distribute metadata in a hub-n-spoke model to multiple software deployments. For example, deployments 'A', 'B', 'C' should all receive metadata that is common to all three. The plan is to setup the common metadata in a central git repo (aka 'common' repo)

However, the local deployments can also create their own metadata. Hence, deployment 'C' can add new stuff to extend what it gets from the hub-n-spoke common repo.

is there a way in Git to setup each hub to have their own git repo that will extend the common repo? I've read something about sub modules Does that address this issue?

Upvotes: 1

Views: 1518

Answers (2)

musingsole
musingsole

Reputation: 1227

Your model can be achieved with branching.

Step 1: You create a main or root branch and populate it with your configuration files. Step 2: Sub-projects create a branch off of root, and begin editing files as they choose.

...

Step N: To update a child's metadata data, the child project simply pulls updates from the root branch and merges as needed. The child project would fully inherit all changes from the parent with full freedom to diverge as it chooses (at the maintainers discretion).

This can be augmented with git submodules, where the project consuming the configuration data creates a submodule that is a fork of the original root branch.

Upvotes: 0

ilya.lehchylin
ilya.lehchylin

Reputation: 101

Looks like the answer to your question is that you should really use submodules (if I get you right). So you will have:

  • Common repository:
    • Submodule repository A
    • Submodule repository B
    • Submodule repository C

Here you can see a simple repository with one submodule.

Working with submodules.

Upvotes: 1

Related Questions