How to Self-Host a Git Repository with Git Dumb HTTP
Goal: self-host a Git repository on your server, allowing read-only clones via HTTP and a web view — using only a static file server (no CGI, no special server modules).
Gitmal’s --git flag generates Git’s dumb HTTP protocol
files alongside the static HTML pages. Any static file server (Caddy, nginx, etc.) can serve both the web UI and
the Git repository data.
Generate the site
Run gitmal with --git flag in your repository:
gitmal --git --output /var/www/html/repo .
This generates:
| Path | Purpose |
|---|---|
index.html, blob/, commit/, … |
Static web view |
HEAD |
Git protocol: default branch |
info/refs |
Git protocol: advertised refs |
refs/heads/* |
Git protocol: branch pointers |
refs/tags/* |
Git protocol: tag pointers |
objects/ |
Git objects (hardlinked from .git/objects) |
objects/info/packs |
Git protocol: pack file index |
Use a TOML config to host multiple repositories on one site:
site_name = "My Git Host"
[[repos]]
name = "nix-config"
slug = "nix-config"
path = "/home/user/nix-config"
default_branch = "main"
gitmal --config repos.toml --git --output /var/www/html
Serve with Caddy
caddy file-server --root /var/www/html --listen :8080
Clone
git clone http://example.com:8080/repo