upstream field of the create-repository request, repos.create,
sets the host to sync from. The SDK and the HTTP API use the same field. base_repo is a one-time
copy of a Code Storage repository; upstream is a lasting link to an external Git host.
Use Generic Sync when you want to:
- Mirror a repository from GitLab, Bitbucket, Gitea, Forgejo, Codeberg, or SourceHut
- Push to Code Storage and let Code Storage forward those writes to the upstream host
- Continue to use Code Storage APIs, JWT-backed remotes, ephemeral branches, and webhooks on the mirrored repository
Sync modes
Code Storage currently supports three Git Sync modes:
This page covers Generic HTTPS Git. For GitHub, see GitHub Sync.
Supported providers
Generic Git Sync supports named providers that authenticate over HTTPS with a username and password, or with a token:gitlabbitbucketgiteaforgejocodebergsr.htorsourcehut
gitlab->gitlab.combitbucket->bitbucket.orgcodeberg->codeberg.orgsr.ht->git.sr.ht
upstream.host in the SDK and the HTTP API) for each self-hosted provider. Also set
it for providers with no fixed public host, such as gitea and forgejo.
Generic HTTPS Git sync does not support Git LFS.
Generic Git setup
Generic provider setup happens in three steps:- Create the Code Storage repository with a generic Git upstream.
- Store the HTTPS credential for that repository.
- Start the initial pull.
1. Create the synced repository
This example creates a Code Storage repository with GitLab as its upstream. For a self-hosted GitLab instance, includeupstream.host. Set PIERRE_ORG and PIERRE_PRIVATE_KEY as shown in the
Quick Start.
upstream.host:
repo_name of the create result in the SDK, or the request
path in the HTTP API. Replace my-custom-repo in the HTTP examples with the name of your
repository.
2. Store the Git credential
Create a credential record for the repository. Providers that accept a token alone do not needusername.
3. Trigger the initial pull
How Git Sync behaves
After you configure Git Sync, these rules apply:git clone,git fetch, andgit pullread from Code Storagerepos.upstream.pullandPOST /api/repos/{repo_name}/upstream/pullstart an asynchronous refresh from the configured provider- Code Storage forwards each
git pushto the external Git host - A successful push starts a background sync to keep the Code Storage nodes current
+ephemeral remote stay in Code Storage. A sync from the external host
copies only refs/heads/* and refs/tags/*. Put machine state on ephemeral branches to keep it out
of the upstream repository. Machine state includes agent snapshots, preview builds, and scratch
commits.