Problem
Difficult to modularize code and maintain separate repos. Submodules are difficult or problematic to use.
Solution
Git Subtrees allow you to track and update a repo within a repo without the headache of submodules.
For a more in depth read on what / why - check out Vinicius’ awesome article.
Setup
Add remote to repo:
git remote add my-subtree [email protected]:account/project.git
Add subtree
git subtree add --prefix=path/to-repo repo-name branch
Push back to subtree’s repo:
git subtree push --prefix=path/to-repo repo-name branch
Pulling changes from subtree’s repo back to main repo:
git subtree pull --prefix=path/to-repo repo-name branch
Reference: https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844