- mirror a repository from GitHub, GitLab, Bitbucket, Gitea, Forgejo, Codeberg, or SourceHut
- push to Code Storage and have those writes forwarded to the upstream provider
- keep using Code Storage APIs, JWT-backed remotes, ephemeral branches, and webhooks on the mirrored repo
Sync modes
Code Storage currently supports three Git Sync modes:| Mode | Best for | Authentication |
|---|---|---|
| GitHub App | Private GitHub repositories and webhook-driven sync | GitHub App installation token |
| Public GitHub | Public GitHub repositories you want to pull from without credentials | No GitHub credentials |
| Generic HTTPS Git | GitLab, Bitbucket, Gitea, Forgejo, Codeberg, SourceHut, and similar hosts | Stored username/password or token |
GitHub App sync
GitHub has the most direct SDK flow today. Create the repository with a GitHub base, then callpullUpstream() whenever you want to force a refresh.
- reads come from Code Storage
- pushes to Code Storage are forwarded to GitHub
- successful pushes trigger a background sync back into Code Storage storage nodes
Public GitHub mode
If the upstream repository is public, you can skip GitHub App auth and create a synced repository in public mode.- no GitHub App webhooks
- no authenticated access to private repositories
- no write-through pushes back to GitHub
Generic HTTPS Git sync
Generic Git Sync covers named providers that authenticate over HTTPS using a username/password pair or a token:gitlabbitbucketgiteaforgejocodebergsr.htorsourcehut
gitlab->gitlab.combitbucket->bitbucket.orgcodeberg->codeberg.orgsr.ht->git.sr.ht
gitea and
forgejo, pass upstream_host when you create the repo.
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 repo
- trigger an initial pull
1. Create the synced repository
This example creates a repository backed by GitLab. For self-hosted instances, includeupstreamHost / upstream_host.
upstreamHost / upstream_host:
repo_id. Use that value in the next step.
2. Store the Git credential
Create a credential record for the repository.username is optional for providers that accept a token on its own.
3. Trigger the initial pull
How Git Sync behaves
Once a repository is configured for Git Sync:git clone,git fetch, andgit pullread from Code Storagerepo.pullUpstream()andPOST /api/v1/repos/pull-upstreamtrigger an async refresh from the configured providergit pushto the default remote is forwarded to the external Git host- successful pushes trigger background sync so Code Storage storage nodes stay current
Git Sync vs Forking vs Imports
| Workflow | Source | Ongoing connection | Best for |
|---|---|---|---|
| Git Sync | External Git provider | Yes | Repositories that should stay mirrored |
| Forking | Code Storage repository | No | Templates, snapshots, isolated copies |
| Imports | External or local Git repo | No | One-time ingestion and migration |