|
| 1 | +# Vendored repositories via squashed `git subtree` |
| 2 | + |
| 3 | +Use this when you want upstream code (for example a separate **docs** site repo, or a library monorepo) inside this project **without** carrying the full upstream history—only periodic squashed imports. |
| 4 | + |
| 5 | +## Local source of truth (`.repos`) |
| 6 | + |
| 7 | +Trees under `.repos/<name>` are the **authoritative local copy** for how we reason about those upstream projects in _this_ repo. When you implement against, debug, or document behavior of a vendored library or service (for example Effect from `effect-smol`, or Dokploy’s server/API surface), **prefer reading and citing the code and bundled docs inside `.repos`** over guessing from npm types, third-party summaries, or stale web pages. Treat each prefix as the canonical reference for that dependency until you refresh it with `git subtree pull`. |
| 8 | + |
| 9 | +Currently tracked: |
| 10 | + |
| 11 | +| Prefix | Upstream | Branch | |
| 12 | +| ------------------------- | --------------------------------------------------------------------------- | -------- | |
| 13 | +| `.repos/effect` | [Effect-TS/effect-smol](https://github.com/Effect-TS/effect-smol) | `main` | |
| 14 | +| `.repos/tanstack-router` | [TanStack/router](https://github.com/TanStack/router) | `main` | |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +- This directory must be a **git repository** with at least one commit on the current branch (use `git commit --allow-empty -m "Initial commit"` if the tree is otherwise empty). |
| 19 | +- Pick a **prefix** path where the subtree will live. Existing convention: `.repos/<short-name>` (example: `.repos/effect` for [effect-smol](https://github.com/Effect-TS/effect-smol)). For a documentation-only repo, `.repos/docs` is a reasonable choice. |
| 20 | + |
| 21 | +## Add a repository (squashed, no upstream history) |
| 22 | + |
| 23 | +Replace the URL, branch, and prefix as needed. |
| 24 | + |
| 25 | +```bash |
| 26 | +git subtree add --prefix=.repos/docs https://github.com/OWNER/REPO-NAME main --squash |
| 27 | +``` |
| 28 | + |
| 29 | +- `--prefix` — directory that will contain the cloned tree; Git creates it. |
| 30 | +- Last argument before `--squash` — upstream branch (often `main` or `master`). |
| 31 | +- `--squash` — produces a single “squashed” commit for the imported tree instead of replaying every upstream commit. |
| 32 | + |
| 33 | +Resulting history will look like: one commit that merges the squashed import into your branch. |
| 34 | + |
| 35 | +## Update from upstream (squashed) |
| 36 | + |
| 37 | +When you want to pull newer commits from the same repo and branch: |
| 38 | + |
| 39 | +```bash |
| 40 | +git subtree pull --prefix=.repos/docs https://github.com/OWNER/REPO-NAME main --squash |
| 41 | +``` |
| 42 | + |
| 43 | +Resolve any merge conflicts if they appear, then commit as usual. |
| 44 | + |
| 45 | +## Optional: shortcut with a named remote |
| 46 | + |
| 47 | +```bash |
| 48 | +git remote add docs-upstream https://github.com/OWNER/REPO-NAME |
| 49 | +git subtree pull --prefix=.repos/docs docs-upstream main --squash |
| 50 | +``` |
| 51 | + |
| 52 | +## Notes |
| 53 | + |
| 54 | +- Subtree imports are **normal files** in your repo; there is no nested `.git` inside the prefix. |
| 55 | +- Document the chosen **URL**, **branch**, and **prefix** in your team’s onboarding or runbook so future updates use the same values. |
| 56 | +- Keep the **Local source of truth** table above in sync whenever you add or rename a subtree under `.repos`. |
| 57 | +- For pushing changes _back_ to the upstream repo, `git subtree split` is possible but uncommon for read-only vendoring; treat the subtree as imported unless you intentionally maintain a fork workflow. |
0 commit comments