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.
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 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
repos.upstream.pullon 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