Overview
Discover what makes Cgit powerful
Cgit is a **hyper‑fast, CGI‑based web front‑end for Git repositories** written in C. It exposes a lightweight HTTP interface that renders repository data on demand, caching the resulting HTML to keep response times low. The core idea is to provide a minimal yet feature‑rich browsing experience without the overhead of a full web application stack. Cgit is distributed under GPLv2, making it free to use and modify for internal or public deployments.
Repository browsing
Dumb HTTP transport
Atom feeds
On‑the‑fly archives
Overview
Cgit is a hyper‑fast, CGI‑based web front‑end for Git repositories written in C. It exposes a lightweight HTTP interface that renders repository data on demand, caching the resulting HTML to keep response times low. The core idea is to provide a minimal yet feature‑rich browsing experience without the overhead of a full web application stack. Cgit is distributed under GPLv2, making it free to use and modify for internal or public deployments.
Key Features
- Repository browsing: logs, diffs (inline and side‑by‑side), tree views, commit statistics, author/committer filters.
- Dumb HTTP transport: cloneable URLs that implement the Git HTTP protocol, allowing
git cloneover plain HTTP. - Atom feeds: per‑repository commit streams in Atom format for integration with RSS readers or CI pipelines.
- On‑the‑fly archives: tar/zip generation for tags and commits without pre‑creating archive files.
- Plugin architecture: dynamic loading of shared libraries for syntax highlighting, custom filters, or other extensions.
- Lua scripting: an embedded interpreter that powers a flexible filtering framework (e.g.,
grep,pretty-blob-view). - Virtual hosting: macro expansion to serve multiple repositories from a single CGI instance.
Technical Stack
| Layer | Technology |
|---|---|
| Language | C (ANSI‑C, portable across Unix‑like systems) |
| Runtime | CGI via mod_cgi or standalone FastCGI; no database required |
| HTTP | Standard CGI interface, optionally behind Nginx/Apache for load balancing |
| Templates | Built‑in HTML templates with placeholder macros; can be overridden by custom CSS/JS |
| Data storage | Git objects on disk; no external DB (caching uses file‑based ETag/mtime checks) |
| Extensions | Shared objects (.so / .dll) loaded at runtime; Lua scripts stored in a filter/ directory |
The absence of a heavyweight framework makes Cgit extremely small (≈ 200 KB binary) and fast to compile, while still being highly configurable through a plain text config file (cgitrc).
Core Capabilities & APIs
- HTTP API:
GET /repo/commit/<hash>returns HTML;GET /repo/archive/<ref>.tar.gzstreams an archive. The server also supports the Git smart HTTP protocol forgit clone, but primarily implements the dumb protocol. - Atom API:
/repo/atomdelivers a feed of recent commits, consumable by any Atom‑compatible client. - Plugin API: Functions exported from plugins can be invoked during rendering (e.g., syntax highlighters). The API is documented in the source under
plugins/. - Lua API: Filters expose Git data via Lua tables; developers can write custom filtering logic without recompiling Cgit.
Deployment & Infrastructure
- Self‑hosting: Runs on any POSIX system with a C compiler and standard libraries. No external services needed beyond the web server.
- Scalability: Because each request is stateless, horizontal scaling is achieved by running multiple CGI instances behind a load balancer (Nginx
fastcgi_passor ApacheProxyPass). Cgit’s caching layer reduces disk I/O, making it suitable for repositories with high read traffic. - Containerization: Official packages exist for Arch, Gentoo, Fedora/RHEL/CentOS, OS X, OpenSUSE, NetBSD, and FreeBSD. Docker images are available on GitHub Container Registry (
ghcr.io/zx2c4/cgit), allowing quick spin‑up in CI/CD pipelines. - Resource footprint: Minimal RAM usage (< 10 MB per instance) and negligible CPU overhead, making it ideal for edge or embedded deployments.
Integration & Extensibility
- Plugins: Add syntax highlighters (e.g.,
highlight.jswrapper), custom diff formats, or external search backends. Plugins are loaded via theplugin_dirdirective incgitrc. - Webhooks: While Cgit itself does not provide outbound webhooks, its integration with Gitolite or pre‑push hooks can trigger external services (e.g., CI jobs) when new commits are pushed.
- Custom templates: Override HTML fragments to match corporate branding or integrate with single‑sign‑on systems.
- Virtual hosting: Use
repo_pathandurl_prefixmacros to expose multiple repositories under a single domain, simplifying DNS management.
Developer Experience
- Configuration:
cgitrcis a simple key/value file; most settings are self‑explanatory. The--helpflag prints available options, and the source contains extensive comments. - Documentation: The README covers build steps, packaging, and advanced configuration. The FAQ addresses common pitfalls (e.g., CGI timeouts, cache invalidation).
- Community: Mailing list (
cgit@zx2c4.com) and IRC channel (#cgit on Libera.Chat) provide active support. The project is actively maintained with frequent releases, and contributors are encouraged to submit patches via the Git repo.
Use Cases
- Enterprise Code Browsing: Deploy a single Cgit instance to host internal Git repositories, providing developers with fast read access without exposing the raw Git server.
- Open‑Source Project Portals: Host public repos with minimal overhead; the lightweight binary fits well on inexpensive VPS or even Raspberry Pi.
- **
Open SourceReady to get started?
Join the community and start self-hosting Cgit today
Related Apps in development-tools
Hoppscotch
Fast, lightweight API development tool
code-server
Self-hosted development-tools
AppFlowy
AI-powered workspace for notes, projects, and wikis
Appwrite
All-in-one backend platform for modern apps
PocketBase
Lightweight Go backend in a single file
Gitea
Fast, lightweight self-hosted Git platform
Weekly Views
Repository Health
Information
Explore More Apps
MistServer
Open‑source OTT streaming toolkit for developers
GoToSocial
Self-hosted apis-services
Wallos
Track subscriptions, manage finances, stay in control
SRS (Simple Realtime Server)
High‑performance real‑time video streaming server
Typesense
Fast, typo‑tolerant search engine for instant results
Paaster
Secure, private pastebin with end‑to‑end encryption
