One of the problems I’ve been working with for some time with Git is using a single clone of a submodule with multiple containing repositories. I tried using symbolic links, but Git refuses to interpret the symbolic links as real submodules. Then I found an interesting workaround via the Git configuration:
- Set up the repositories individually, as you would normally do.
- Choose a location to place the submodule. Place exactly one checkout of the submodule there.
- Delete the submodule directory from all other locations. In their place, add an empty directory (for compatibility reasons).
git config --local submodule.SubmoduleName.path /path/to/submodulein each repository you want to share the submodule between. The path should either be relative to the repository root or absolute.
Now you have a single checkout of the submodule shared among all repositories. I made a sample repository using SpongeForge and SpongeVanilla; you can view it here. See the README file for usage instructions; the
init script contains all the logic.