Commit 10a0c7f

HPCesia <me@hpcesia.com>
2026-07-02 04:40:55
Update README and doc for dumb HTTP protocol usage
1 parent b1661d0
docs/how-to-self-host-a-git-repository.md
@@ -1,67 +1,83 @@
-# How to Self-Host a Git Repository?
+# How to Self-Host a Git Repository with Git Dumb HTTP
 
-**Goal**: self-host a Git repository on your server, allowing read-only clones and a web view.
+**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).
 
-Create a _git_ user on the server where you want to host the repository. This step is optional, but I like to use a
-dedicated user for repository management to keep the system secure and organized.
+Gitmal's `--git` flag generates Git's [dumb HTTP protocol](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols)
+files alongside the static HTML pages. Any static file server (Caddy, nginx, etc.) can serve both the web UI and
+the Git repository data.
 
-Create a `~/public` directory, which will serve as the web root. Configure a web server to serve files from this
-directory.
+## Generate the site
 
-## Bare repo
+Run gitmal with `--git` flag in your repository:
 
-Create a bare repository inside `~/public`.
-A [bare repository](https://git-scm.com/book/en/v2/Git-on-the-Server-The-Protocols)
-is a special type of Git repository that doesn't have a working directory. It's used for hosting and sharing code
-without the need for a local working copy.
+```sh
+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:
+
+```toml
+site_name = "My Git Host"
+
+[[repos]]
+name = "nix-config"
+slug = "nix-config"
+path = "/home/user/nix-config"
+default_branch = "main"
+```
 
 ```sh
-git init --bare repo.git
+gitmal --config repos.toml --git --output /var/www/html
 ```
 
-Create a [post-update](https://git-scm.com/docs/git-receive-pack#_post_update_hook) hook with the following content:
+## Serve with Caddy
 
 ```sh
-#!/bin/sh
-exec git update-server-info
+caddy file-server --root /var/www/html --listen :8080
 ```
 
-Make the hook executable:
+## Clone
 
 ```sh
-chmod +x hooks/post-update
+git clone http://example.com:8080/repo
 ```
 
-## Gitmal hook
+## Post-receive hook (auto-update on push)
 
-Create a [post‑receive](https://git-scm.com/docs/git-receive-pack#_post_receive_hook) hook with the following content:
+To regenerate the site automatically on each push, create a
+[post-receive](https://git-scm.com/docs/git-receive-pack#_post_receive_hook)
+hook in your bare repository:
 
 ```sh
 #!/bin/sh
-exec gitmal --output /home/git/public/repo/
+gitmal --git --output /var/www/html/repo /path/to/repo.git
 ```
 
-Make the hook executable:
-
 ```sh
 chmod +x hooks/post-receive
 ```
 
-## Publish
-
-Push your local repository to the bare repository on the server using ssh protocol.
-
-```sh
-git remote add origin git@example.com:public/repo.git
-git push origin master
-```
+Now every `git push` triggers a fresh build, and clients can clone immediately via HTTP.
 
-After pushing, git will run gitmal and generate files under `~/public/repo/` directory.
+## Private read-write access
 
-- Private read-write clone URL: `git@example.com:public/repo.git`
-- Public **read-only** clone URL: `http://example.com/repo.git`
-- Gitmal static web view: `http://example.com/repo/`
+Keep the SSH protocol for private write access:
 
 ```sh
-git clone https://example.com/repo.git
+git remote add origin git@example.com:repo.git
+git push origin main
+git clone http://example.com/repo   # public, read-only
 ```
README.md
@@ -29,12 +29,48 @@ Run gitmal in the repository dir. Gitmal will generate pages in _./output_ direc
 gitmal .
 ```
 
-Run gitmal with `--help` flag, go get a list of available options.
+Run gitmal with `--help` flag to get a list of available options.
 
 ```sh
 gitmal --help
 ```
 
+Generate static files for Git dumb HTTP protocol (enables `git clone` via HTTP):
+
+```sh
+gitmal --git .
+```
+
+Generate multiple repositories with a TOML config file:
+
+```sh
+gitmal --config repos.toml
+```
+
+Example `repos.toml`:
+
+```toml
+site_name = "My Git Host"
+
+[[repos]]
+name = "nix-config"
+slug = "nix-config"
+path = "/home/user/nix-config"
+default_branch = "main"
+
+[[repos]]
+name = "dotfiles"
+slug = "dotfiles"
+path = "/home/user/dotfiles"
+default_branch = "master"
+```
+
+Filter branches with a regular expression:
+
+```sh
+gitmal --branches '^(main|master)$' .
+```
+
 ## Screenshots
 
 <p align="center">