upstream field of the create-repository request sets the host to sync from.
base_repo is a one-time copy of a Code Storage repository; upstream is a lasting link to an
external Git host. The SDK baseRepo option still sends the deprecated base_repo form, which
works the same.
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 HTTP API, upstreamHost in the SDK) 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 base.
- 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, includeupstreamHost in the SDK, or upstream.host in the HTTP API.
upstreamHost in the SDK, or upstream.host in the HTTP API:
repo_id. Use that value in the next step.
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 Storagerepo.pullUpstream()andPOST /api/repos/{repo_name}/pull-upstreamstart 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.
Related reference pages
- Create repository
- Git credentials
- Pull from upstream
- createRepo()
- createGitCredential()
- pullUpstream()
- GitHub Sync
- Repository Forks