let upper, left, and right be directories as in the following diagram.
upper
├── left
└── right
question
how do i best manage these with git as local git repositories such that
- each
upper,leftandrighthas a separate git repository, - histories from the repositories of
leftandrightcan be somehow propagated to the repository ofupper, - histories from the repository
uppercan be somehow propagated to the repositories ofleftandright,
both of the latter preferably being done without changing the corresponding work-trees upper, left, and right?
example
for clarity, call the git repositories of upper, left and right just upper.git left.git and right.git respectively. (you can imagine them as bare repositories entirely outside the mentioned directory structure.) first
- i work on
leftand commit toleft.git; then - i somehow propagate the history from
left.gittoupper.git, so the latter knows about all the work i have done; then - i work on
upper, sometimes working on files inright, and commit toupper.git; then - i somehow propagate the history from
upper.gittoright.git, so the latter knows about all the work i have done on files inright.
thoughts
initially i thought that i could realise this by using git subtree. but when i try to include the repository for left in upper using git subtree -P left add ⟨left.git⟩ master, i - perhaps unsurprisingly - get:
fatal: prefix 'left' already exists.
i have searched similar questions on stackoverflow, regarding nested repositories, but i quite don’t see how they relate to my problem. i probably don’t understand git subtrees well enough and perhaps i’m a bit too simple-minded in general. i have not looked deeply into git submodules; it seems to me that they are meant for something else.