Git Subtree Guide
Use Git subtree to include external repositories within your project as a subdirectory. Unlike submodules, subtrees are simpler for contributors and don't require special commands to clone.
Usage
Ask about adding subtrees, syncing changes, or choosing between subtree and submodule for your use case.
Examples
- "How do I add an external repo as a subtree?"
- "How do I pull upstream changes into my subtree?"
- "When should I use subtree vs submodule?"
Guidelines
- Use subtree when contributors should not need to know about the external repo
- Use the squash option to keep your history clean when adding subtrees
- Pull upstream changes regularly to stay current
- Push changes back upstream if you modify subtree code
- Prefer subtree over submodule for simpler workflows