Git Subtree
ELI5 - The Vibe Check
Git subtree lets you fold an entire external repository into a subfolder of your own, history and all, as if it had always lived there. Unlike a submodule, which is basically a labeled pointer to someone else's repo that you have to remember to update separately, a subtree actually copies the code and commits in, so anyone who clones your repo gets everything in one shot with zero extra setup.
Real Talk
git subtree merges the history of another repository into a subdirectory of the current repository using the merge strategy of the same name, producing a self-contained copy that requires no special client-side setup to clone or build, unlike git submodule, which stores only a reference commit pointer that must be explicitly initialized and updated. The tradeoff is that subtree bloats the parent repository's history with the vendored project's commits, while submodule keeps history separate but adds an extra layer most contributors forget to update.
When You'll Hear This
"We vendored it in with subtree so nobody has to remember to init a submodule." / "Subtree bloats our history, but at least clones just work out of the box."
Related Terms
Git Object Model
Under the hood, git doesn't actually store files and folders the way your operating system does.
Merge
Merge is like combining two parallel universes back into one. You take the changes from your branch and smoosh them into another branch.
Repository (Repo)
A repository (repo) is a folder that Git is watching. It contains all your project files plus the entire history of every change ever made.
Submodule
A submodule is a repo inside another repo. It's like embedding someone else's project inside yours.