Skip to content

Git over HTTPS

Amendable speaks Git Smart HTTP. If git clone works against GitHub over HTTPS, it works here. There is no SSH remote.

https://amendable.io/r/<username>/<repo>.git

Info refs:

GET https://amendable.io/r/<username>/<repo>.git/info/refs?service=git-upload-pack
GET https://amendable.io/r/<username>/<repo>.git/info/refs?service=git-receive-pack

You rarely call those yourself. git does.

Git uses HTTP Basic. The password is the access token. See Authentication.

Terminal window
git clone "https://USER:${AMENDABLE_TOKEN}@amendable.io/r/USER/REPO.git"

Works, but the token lands in .git/config. After the clone:

Terminal window
git remote set-url origin "https://amendable.io/r/USER/REPO.git"

Required grants (Grants):

  • Clone and fetch: GIT_HTTP_READ
  • Push: GIT_HTTP_WRITE (read is added automatically)

Empty repositories accept whichever branch you push first. Until the first push, GET /v1/repos/{user}/{repo}/branches is 200 with {"branches":[],"default_branch":"master"}. GET /v1/repos/{user}/{repo}/commits on the same empty repo is 404 No commit found in the repository. That 404 is for commits, not branches.

Terminal window
git switch -c main
git add .
git commit -m "Initial commit"
git push -u origin main

The first commit may also have an empty tree (no files). That matches GitHub and GitLab. Agent bootstraps often start this way with git commit --allow-empty:

Terminal window
git switch -c main
git commit --allow-empty -m "Initialize repository"
git push -u origin main

After the first push, GET /v1/repos/{user}/{repo}/branches lists each branch tip and default_branch is the branch you pushed. That endpoint needs API_COMMITS_READ or ALL.

A later force-push is a normal Git push. Clones see the new tip. The previous push is still an immutable layer, so rewritten Git history does not erase earlier changes. See Auditable history.

import os
from urllib.parse import quote
import pygit2
user = os.environ["AMENDABLE_USERNAME"]
token = os.environ["AMENDABLE_TOKEN"]
repo = os.environ["AMENDABLE_REPO"]
url = f"https://{quote(user)}:{quote(token)}@amendable.io/r/{user}/{repo}.git"
callbacks = pygit2.RemoteCallbacks()
pygit2.clone_repository(url, "/tmp/amendable-clone", callbacks=callbacks)

Any HTTPS Git library works. There is no custom Git protocol.

To list a directory or download a file over the REST API without cloning, see Fetch files.

Clone and fetch count as transfer (egress). So do contents API response bodies. Push bodies count as ingress (metered, not billed). Free accounts include 5 GiB transfer per UTC month. Hitting the free cap returns an error on Git HTTP and on contents downloads. Paid plans have included transfer plus overage.