repo.fork() creates a new repo that starts as an exact copy of the source. Nothing is copied up front: the fork’s data
is a copy-on-write branch of the source repo’s disk, so a fork is ready in about a
second whatever the repo’s size. Use forks to give each agent run, experiment, or user its own repo that starts from a
known state, without waiting for a clone.
archil.git.repos.fork(repoId, { name, ref? }) when you have only the ID.
What a fork gets
- A consistent copy. The fork has every branch and tag the source had at the moment of the fork, and its LFS objects. A push or commit that was in progress isn’t half-applied in the fork.
- Its own repo. A fork is a repo like any other, with its own ID, name, and remote URL. It appears in
repos.list(), works with the read API, and can be forked again.forkOfnames the source. - Isolation. Writes to the fork never reach the source, and writes to the source never reach the fork.
- Separate tokens. A token minted for the source doesn’t open the fork, and the reverse. Mint tokens for the fork
by its ID or
Repo. - Its own webhooks. The fork’s starting state sends no webhook. Its own pushes and commits do, with the fork’s repo ID.
Start the fork at another ref
By default, the fork’s refs are exactly the source’s. Passref to point the fork’s default branch at a different
branch, tag, or commit of the source. The default branch keeps the source’s name.
Delete a fork
Deleting a fork is immediate: it disappears from listings, and its tokens stop working. A repo that still has live forks can’t be deleted on its own, because its forks share its disk. The call fails with codehas_forks (HTTP 409), and forks lists them, each with id and name. Delete the forks first, or pass
cascade to delete them with the repo:
Notes
- A fork’s
diskIdis the disk of the original repo, which the whole family shares. The fork’s data is on its own branch of that disk. - Forking takes a name that follows the same rules as
repos.create, and must not already be taken.