Aaron Holbrook
I'm Aaron Holbrook: a web engineer, father, gamer and geek.

Git Subtrees – A Primer


Difficult to modularize code and maintain separate repos. Submodules are difficult or problematic to use.


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.


1. Add remote to repo:
git remote add my-subtree [email protected]:account/project.git

2. Add subtree
git subtree add –prefix=path/to-repo repo-name branch

Pushing back to subtree’s repo:
1. git subtree push –prefix=path/to-repo repo-name branch

Pulling changes from subtree’s repo back to main repo:
1. git subtree pull –prefix=path/to-repo repo-name branch

Reference: https://medium.com/@v/git-subtrees-a-tutorial-6ff568381844