0

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, left and right has a separate git repository,
  • histories from the repositories of left and right can be somehow propagated to the repository of upper,
  • histories from the repository upper can be somehow propagated to the repositories of left and right,

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 left and commit to left.git; then
  • i somehow propagate the history from left.git to upper.git, so the latter knows about all the work i have done; then
  • i work on upper, sometimes working on files in right, and commit to upper.git; then
  • i somehow propagate the history from upper.git to right.git, so the latter knows about all the work i have done on files in right.

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.

windfish
  • 101
  • 2

1 Answers1

1

It's not quite clear what is your ultimate goal for such a structure. If you only plan on keeping all these repos local - there is no need for submodules.

If you want upper repo (not folder) to contain all changes from inner repos (separate commit tree) you could try some answers from here.

On the other hand I don't see any reason to do so. If all you want is just keep changes of folders in different repositories - create independent repos, and treat them as such. In this case upper.git repo (not folder) will ignore all changes of inner repos. Each inner repo will keep track of it own folder.

markalex
  • 8,623
  • 2
  • 7
  • 32