Skip to main content
A fork is an independent copy of an existing Code Storage repository. It starts from one source commit and has its own access. After the copy, a change in one repository does not reach the other. In the HTTP API, the base_repo field of the create-repository request sets the source. base_repo is a one-time copy of a Code Storage repository; upstream is a lasting link to an external Git host. To keep a repository in sync with another host, see GitHub Sync and Generic Sync.

When to use a fork

  • Templates: Create new projects from a starter template
  • Experiments: Test changes in an independent repository
  • Snapshots: Capture a repository’s state at a specific commit or branch
  • Isolation: Separate work across a trust or tenant boundary, or give each user an independent project of their own
For per-agent and per-task isolation inside a single repository, use the ephemeral namespace instead. Those branches share the repository’s Git objects and its access, and you can promote the work you keep.

Quick start

Set PIERRE_ORG and PIERRE_PRIVATE_KEY as shown in the Quick Start.
base_repo takes name, ref, and auth.token. ref accepts a branch, a tag, or a commit SHA, and defaults to the HEAD of the source. When you give no auth.token, the SDK signs a git:read token for the source. The new default branch is the top-level default_branch, or else the default branch name of the source. See repos.create for the full parameter list.

Use cases

Project templates

Create new projects from a starter template:

Point-in-time snapshots

Capture a repository’s state before you make risky changes:

Fork or sync

Set at most one of base_repo and upstream in a request. A request with both returns HTTP 400.

Copy a GitHub repository

A fork needs a Code Storage source. To copy a public GitHub repository, create a repository with a public GitHub upstream instead. It needs no GitHub App:
Public GitHub mode runs one import and keeps no continuous sync. The repository keeps its link to GitHub, so it can sync again on request.

Limitations

  • Same organization: You can only fork repositories within your own organization
  • No relationship tracking: Forks are independent. Code Storage keeps no “parent” reference after creation. No route merges a fork back into its source
  • No upstream: A fork records no upstream, so repos.upstream.pull on a fork returns HTTP 400 with repository has no upstream configured. To get later changes, add the source repository as a second Git remote. Fetch and merge the changes
  • One branch: A fork has one branch, at the chosen commit, with the history of that commit. It has no other branches and no tags