Skip to content

gitmode

Git server & client for Cloudflare Workers. Push, clone, branch, merge — all serverless. Install as npm package or import into your Worker.

gitmode ships as an npm package with two entry points for different use cases:

Server — gitmode/server

Full git server for Cloudflare Workers. Smart HTTP transport, 29-endpoint REST API, R2 chunk storage, Durable Objects with SQLite. Uses the 865KB WASM module with libgit2.

import { createHandler, RepoStore, PackWorkerDO } from "gitmode";

Client — gitmode/client

Lightweight git primitives for any JS runtime. SHA-1 hashing, zlib compression, delta encoding. Uses the 83KB WASM module — no server deps, no libgit2.

import { WasmEngineCore } from "gitmode/client";

npm Package

npx gitmode init scaffolds a complete Worker project. Or import directly into your existing Worker for git protocol + REST API routing.

Full Git Protocol

Smart HTTP transport and SSH-to-HTTP proxy. Works with standard git clone, git push, git fetch over both HTTP and SSH.

REST API

29 endpoints for programmatic access. Init repos, commit files, create branches, merge, cherry-pick, revert — all via JSON.

Zig WASM + SIMD128

SHA-1, zlib, packfile parsing, delta encoding — all in Zig compiled to WASM with SIMD acceleration. Two modules: 865KB server, 83KB client.

Durable Objects + R2

Each repo is a Durable Object with embedded SQLite for refs and metadata. Git objects bundled into ~2MB R2 chunks, indexed via SQLite for O(1) lookups.

Security Hardened

Path traversal protection, git refname validation, packfile size limits, varint bounds checks, input validation on all REST endpoints.

Terminal window
# Scaffold a new gitmode Worker
npx gitmode init
npm install
npx gitmode deploy

Or add to an existing Worker:

import { RepoStore, PackWorkerDO, createHandler } from "gitmode";
export { RepoStore, PackWorkerDO };
export default { fetch: createHandler() };
Git Client ──HTTP──▶ Cloudflare Worker ──▶ RepoStore DO (SQLite)
──SSH───▶ SSH Proxy ──HTTP──▶ ──▶ R2 (git objects)
──▶ Zig WASM (SHA-1, zlib, packfiles)

Every repository maps to a single Durable Object instance. The DO’s embedded SQLite stores refs (branches, tags, HEAD), metadata, and an object chunk index. Git objects are bundled into ~2MB R2 chunks for efficient batch reads. Two Zig WASM modules handle binary operations: the server module (865KB) for full git ops, and a core module (83KB) for client-side SHA-1, zlib, and delta encoding.