How to work with submodules and n-tiers git repository strategies
Asked Answered
E

1

5

We are migrating to git. We have a large number of modules that make up our products, some of them are shared between products. The product is represented by a "thin" super repository (ssh://server/product.git) that only contains submodules:

[submodule "module1"]
path=module1
url=ssh://server/product/module1.git
[submodule "module2"]
path=module2
url=ssh://server/product/module2.git
...

I can clone the super repository and work with the submodules and commit them, and then commit the submodules to the super repository.

The problem comes when I want to introduce another tier. There are two basic scenarios (this can combine to make more complex setups, but anything should be a combination of these):

  1. As a developer, I clone a central repository and work. Then I want to submit my code to our continuous integration server before merging my changes to the central repository. I let the CI server clone my repo. This doesn't work, the CI server will clone my super repo and then it will clone the submodules from the central repository location (since that is what it says in .gitmodules).

  2. As a team we want to have an integration repository that we work towards before we, at the end of a sprint, merge our code to the central repository. This fails, for the same reason.

I tried specifying relative URLs for the submodules, but this doesn't work, either, since when we clone the second tier into the third tier the relative URLs resolve relative to the second tier repository location, but the second tier submodule locations are inside the second tier super repository.

Can I have it both? Git submodules and n-tier repository structure?

Edgell answered 6/7, 2011 at 9:10 Comment(1)
See the solution here: #6031994Shcherbakov
B
0

relative links don't work in submodules. Use gitolite to house all your repositories. Your structure will work then.

Other urls also had problems. Examples would be a url like ..\someotherrepo or \\servername\reponame or even file:///\\server\... given for a submodule.

Basilius answered 8/7, 2011 at 0:38 Comment(2)
I read the short overview of gitolite, but I fail to see how it addresses my use case. It handles authentication and authorization for you, but I don't have that problem. A simple example or pointer to relevant documentation would help.Edgell
Gitolite would take care of the ssh stuff plus give you git-friendly urls. Gitolite running on a small ubuntu server vm has done loads for this and other issues. The urls become gitolite@gitserver:somerepo.git and I've had no issues with submodules and that form of URL. It's what solved the same issue for me so I suggested it here. I guess you can wait and see if other answers come up or jump on the #git irc channel?Basilius

© 2022 - 2024 — McMap. All rights reserved.