Gitslice docs
Git Mirrors
Automatically push a slice to GitHub or any other Git host as a live backup or public read-only copy. Gitslice pushes after every landing and tag — no workflow or runner to maintain.
Set up a mirror
A mirror is configured on the slice itself, and only the owning account's owners and admins can view or change it. Store a push token as a slice secret, then point the mirror at the remote repository:
# read the token from stdin so it stays out of shell history
gs slice secret set acme/app GITHUB_MIRROR_TOKEN < token.txt
gs slice mirror set acme/app --url https://github.com/acme/app.git \
--token-secret GITHUB_MIRROR_TOKEN
gs slice mirror acme/app # last push, pending work, last error
gs slice mirror push acme/app # trigger a push now
gs slice mirror rm acme/app # stop mirroringIn the web app, open the slice's Settings and use the Mirror to Git panel below Secrets to set the repository URL, token secret, branch, and username, or to Push now or Stop mirroring. The first push starts immediately on save. CLI mirror commands require gs v0.4.25 or newer (gs upgrade).
- Branch: Defaults to
main; override with--branch. - Username: Sent alongside the token. Defaults to
x-access-token(what GitHub expects); pass--usernamefor GitLab or other Git hosts. - One mirror per slice: Running
gs slice mirror setagain updates the existing mirror configuration.
Create a GitHub token
- Open GitHub's new fine-grained token page (Settings → Developer settings → Personal access tokens → Fine-grained tokens).
- Set the resource owner to the account or organization that owns the repository.
- Under Repository access, choose Only select repositories and pick the target repository.
- Under Repository permissions, set Contents to Read and write. Leave all other permissions at No access.
- Generate the token and store it with
gs slice secret set. The mirror configuration records only the secret's name, never its value.
Pushes authenticated with a fine-grained personal access token trigger GitHub Actions normally, so release and CI workflows listening on branch pushes or new tags keep working.
What is pushed
- Main branch history: One Git commit per landed Gitslice commit on the slice's default target, preserving author, timestamps, and commit message. Each commit includes a
Gitslice-Committrailer so the mirror knows exactly where the remote stands. - Repository root layout: A slice with a single root folder (such as
/acme/app) is pushed with that folder as the Git repository root. A slice spanning multiple root folders is pushed with full paths preserved. - Tags: New slice tags (
gs tag create) are pushed once. A tag already present on the remote is never overwritten or moved. - Existing repositories: An empty remote receives the full slice history. A remote that is already a mirror of the slice resumes cleanly from its last mirrored commit.
When it pushes
- Automatic push: Runs after every landing that touches a path in the slice and after every new tag, typically completing within seconds.
- Retries: A failed push stays pending and is retried after 1 minute, 5 minutes, 30 minutes, 2 hours and 6 hours, then every 12 hours. Nothing is lost while waiting — the next successful push brings the remote completely up to date.
- Status:
gs slice mirrorand the Settings panel report the last pushed commit, whether a push is pending, and the most recent error.
It never force-pushes
The mirror only fast-forwards the remote branch. If someone commits directly to the remote or its tree diverges from the slice, the push stops with an explicit error and never overwrites remote commits. To recover, decide whether to bring those remote commits into Gitslice as a changeset, reset the remote branch to the last mirrored commit, and run gs slice mirror push.
To prevent accidental writes on the mirror, protect the branch on the host. On GitHub, a ruleset blocking force pushes and branch deletion still allows the mirror's fast-forward pushes through.
When the token expires
Expired or revoked tokens produce an authentication error in the mirror status. Generate a new token and overwrite the same secret name — the next retry or gs slice mirror push picks it up automatically:
gs slice secret set acme/app GITHUB_MIRROR_TOKEN < new-token.txt
gs slice mirror push acme/appSecurity
- Public HTTPS targets only: Only
https://URLs resolving to public internet addresses are accepted. The server validates the target IP before dialing and pins Git to the checked address to block DNS rebinding, and HTTP redirects are refused. - Credential hygiene: The push token is passed to Git as an HTTP header via environment variables — never on the command line — and scrubbed from any stored or displayed error message.
- Stored outside the source tree: Mirror URLs and token secret names live in slice settings rather than committed files, so a changeset cannot redirect backups.
- Visibility check: A mirror exports the exact tree a reader of the slice can clone. Confirm the destination repository's visibility before mirroring a private slice.
Current limitations
- One mirror per slice, tracking the slice's default target branch only.
- SSH remotes and GitHub App installations are not supported yet.
- Mirroring is one-way; commits made directly on the remote are not synced back automatically.
Example: Gitslice itself
The public gitslice/gitslice slice mirrors itself this way to github.com/gitslice-io/gitslice. Every landing arrives on GitHub within seconds, and pushing a v* tag triggers the GitHub release workflow automatically.
Secrets
Store and manage encrypted push tokens and folder-scoped secrets.
For Git Users
Clone slices with Git, import existing repos, and publish Go modules.
