简体   繁体   中英

Is it possible to add a submodule to a submodule from the top-level git repository?

I'm working on a few game development projects that use the open-source Godot Engine, which supports modules and add-on scripts.

Our team manages a Git repository for the project, as well as some custom engine modules and add-on script Git repositories, but we don't necessarily want to maintain our own fork of the engine for each project if it isn't necessary. Here's the basic structure:

/project/project.git                              [The project repo. We maintain it.]

/project/engine/engine.git                        [Open-source engine repo. Submodule. We prefer to not maintain a fork if not needed.]

/project/engine/modules/my-module/my-module.git   [One of our custom engine module repos. Submodule. We maintain them.]

In other words, what we'd like to do is add the upstream engine to each of our projects as a submodule at /project/engine . And then we'd like to add various modules to the engine under /project/engine/modules/ , but as submodules of the top-level project repo instead of the engine repo.

(Our thought process is that, in many projects, we can simply attach the unmodified, upstream Godot repository directory, and then add functionality to the engine by attaching modules and add-ons. Each top-level project would be responsible for managing the specific engine, modules, and add-ons that it needs. As such, we can cut down on the number of engine forks or branches that we need to maintain, saving that as a last-resort for situations where modules and add-ons can't be used.)

The problem that we've run into so far is that, once we add the engine as a submodule of the project (at /project/engine ) we don't seem to be able to add another nested submodule (at /project/engine/modules/my-module for example) from the top-level "superproject", I think because the target path exists inside the engine's submodule. We want the project to attach a submodule on behalf of the engine, so that the project is responsible for the change but...

Is that just not possible? Is there no way to add a submodule to the top-level project repository, that targets a path that exists in the one of its submodules?

I'm open to alternative suggestions if there are better ways to manage this kind of setup, though I feel we're already at risk of over-designing our repo structure here.

If your project is on GitHub or on self-hosted Bitbucket, then you can do it with Git X-Modules App - it supports nesting modules, and has a few other features that Git submodules doesn't (such as adding only a specified directory in a repository as a module, etc.).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM