Git Subtree

What it is

  • Inject dependency in a subdirectory
  • Extract a subdirectory as a separate project
  • Solves some of the problems associated with git submodules

Benefits

  • No new interface to learn
  • Stores as regular commits
  • Clean integration points

Other notes

git subtree add --prefix target-folder https://.... main --squash

git ls-remote allows you to list all symbolic names to know what version was pulled into that commit.

Subtree is not good if you have a lot of constant updates to the dependencies

git subtree split --prefix my/project/ --branch extracted
  • splits out entire history of a directory into a new directory