ThoughtCraft
Git Subtrees - A Primer

Git Subtrees - A Primer

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.

{% include responsive-embed url=“http://www.youtube.com/embed/E7YWeRFHpXg” %}

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

Author's Note: I’ve chosen to preserve these thoughts as they were originally shared. Some external links or references may no longer work. I’m leaving them intact to maintain their original context and spirit.