docs/mintlify/cloud/features/collection-forking.mdx
import { Callout } from '/snippets/callout.mdx';
Forking lets you create a new collection from an existing one instantly, using copy-on-write under the hood. The forked collection initially shares its data with the source and only incurs additional storage for incremental changes you make afterward.
<Callout> **Forking is available in Chroma Cloud only.** The storage engine on single-node Chroma does not support forking. </Callout>forked_collection = source_collection.fork(new_name="main-repo-index-pr-1234")
forked_collection.add(documents=["new content"], ids=["doc-pr-1"]) # billed as incremental storage
```typescript TypeScript
const sourceCollection = await client.getCollection({
name: "main-repo-index",
});
// Create a forked collection. Name must be unique within the database.
const forkedCollection = await sourceCollection.fork({
name: "main-repo-index-pr-1234",
});
await forkedCollection.add({
ids: ["doc-pr-1"],
documents: ["new content"], // billed as incremental storage
});
let source_collection = client.get_collection("main-repo-index").await?;
// Create a forked collection. Name must be unique within the database.
let forked_collection = source_collection
.fork("main-repo-index-pr-1234")
.await?;
// Changes are billed as incremental storage
forked_collection
.add(
vec!["doc-pr-1".to_string()],
vec![vec![0.1, 0.2, 0.3]],
Some(vec![Some("new content".to_string())]),
None,
None,
)
.await?;
In this notebook you can find a comprehensive demo, where we index a codebase in a Chroma collection, and use forking to efficiently create collections for new branches.
Chroma limits the number of fork edges in your fork tree. Every time you call "fork", a new edge is created from the parent to the child. The count includes edges created by forks on the root collection and on any of its descendants; see the diagram below. The current default limit is 256 edges per tree. If you delete a collection, its edge remains in the tree and still counts.
If you exceed the limit, the request returns a quota error for the NUM_FORKS rule. In that case, create a new collection with a full copy to start a fresh root.