Commiting changes in nested git subtrees

226 views Asked by At

I have been reading a lot on git subtrees as an alternative submodules and was wondering what is the best way to handle nested subtrees with regards to committing changes:

Say you have project A with a subproject B as a subtree (so A is the parent).
If I make changes to B while working in A, I need to use git subtree push to push the changes onto B.
Similarly, If I make changes to B whilst working in B, to bring these updates in A I need to use git subtree pull

My question is how do you handle committing changes if you add another subproject C which is a subtree in B (ie B is the parent of C). As far as I understand, the below is how you would do it. Is there a better way?

So say you are working in project A and then make changes to C. In order to bring these changes to C, you need to use git subtree push twice:
1. Git subtree push from A to B, then
2. Git subtree push from B to C

Similiary, the reverse is true when making changes in C whilst working within C and git subtree pull

This is a bit repetitive, so I was wondering if there is another way to go about it. Perhaps a better way would to not use subtrees at all? If not, what would be an alternative?

0

There are 0 answers