2

We have a somewhat larger project that is organised in various interdependent git repositories following a tree structure without recursion. In what follows I try to depict the smallest possible example that would highlight the problem I'm trying to address, even if in our case the tree depth can be relatively big. Suppose the system of repositories and submodule dependencies as follows (notation "->" means uses as a submodule):

A
B -> A
C -> A, B

If I use git clone --recursive for C, the following directory structure will happen:

C/
C/A
C/B/A

This repetition will also happen inside the .git directory: you'll find .git/modules/A, .git/modules/B, and .git/modules/B/modules/A. While I understand the reasons for this, in our particular case, it would be useful if the structure would be more like the following (notation: "->" symlink):

C/A
C/B
C/B/A -> C/A

So, if I would update A inside B, it would also be updated in C, and I'd just have to commit the changes to those repos and they would stay in sync. Is this possible somehow within git? Are there practical solutions to this issue?

André Anjos
  • 3,763
  • 1
  • 26
  • 34
  • 3
    Git itself won't do this. It probably should do some of it automatically—it probably should make sets out of the various URLs involved, and notice when some are the same—but that would fail to handle minor URL variances, e.g., when a hostname is spelled with an IP address in just one of them, or one ends in `.git` and another doesn't, or various other possibilities. So you'll need your own tool for this. Unfortunately there's no simple way to write such a tool either. – torek Mar 24 '19 at 17:57

1 Answers1

0

You can also link the other way around :

# at the root of C
ln -s B/A A
LeGEC
  • 35,975
  • 2
  • 46
  • 87