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
Quick start
SetPIERRE_ORG and PIERRE_PRIVATE_KEY as shown in the
Quick Start.
baseRepo takes id, ref, and sha. In the HTTP API, 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. The new default branch is the top-level default_branch, or else the default branch name of
the source. See createRepo() for the full parameter list and resolution
order. That page also explains which default branch the fork inherits.
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
In the HTTP API, a fork is
base_repo and a sync is upstream. Set at most one of them 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 GitHubupstream instead. It needs no GitHub App:
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
pullUpstream()on a fork returns HTTP400withrepository 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