Show HN: Pgit – A Git-like CLI backed by PostgreSQL

Pgit is a Git-like CLI that stores repository history in PostgreSQL, enabling full SQL access to every commit and file version while achieving high compression ratios.
TL;DR: Built a Git-like CLI backed by PostgreSQL with automatic delta compression. Import any git repo, query its entire history with SQL. Benchmarked on 20 real repositories (273,703 commits): pgit outcompresses git gc --aggressive on 12 out of 20 repositories, while giving you full SQL access to every commit, file version, and change pattern. Then I gave an AI agent a single prompt and it produced a full codebase health report on Neon's own repo in under 10 minutes.
What is pgit?
pgit is a Git-like version control CLI where everything lives in PostgreSQL instead of the filesystem. You get the familiar workflow (init, add, commit, push, pull, diff, blame), but your repository is a database. And that means your entire commit history is queryable.
pgit init
pgit import /path/to/your/repo --branch main
pgit analyze coupling
No scripts. No parsing git log output. No piping things through awk. Just answers.
The most common analyses are built in as single commands: churn, coupling, hotspots, authors, activity, and bus-factor. All support --json for programmatic consumption, --raw for piping, and display results in an interactive table with search and clipboard copy.
But everything is PostgreSQL underneath. When the built-in analyses aren't enough, drop down to raw SQL.
Why Did I Build It?
After building xpatch, a delta compression library that hits 2-byte medians on real code repositories, I kept asking myself: "Where could delta compression be useful where it isn't used yet?"
Databases were the obvious answer. Every application that stores versioned data (document editors, audit logs, config history) is keeping full copies of content that's 99% identical to the previous version. Delta compression could save massive amounts of storage, but nobody builds it into the database layer itself.
So I started building pg-xpatch: a proper PostgreSQL Table Access Method that does delta compression transparently. PostgreSQL's extension API is powerful, and the results were immediately promising.
Benchmarks: git vs pgit
I benchmarked pgit against git on 20 real repositories across 6 languages, totaling 273,703 commits. The comparison is pgit's actual compressed data size versus git gc --aggressive packfile size, the best git can do.
The scorecard: pgit 12 wins, git 8 wins.
| Repository | Commits | Raw Size | git --aggressive | pgit | Winner | |---|---|---|---|---|---| | serde | 4,353 | 203.5 MB | 5.6 MB | 3.9 MB | pgit (30%) | | ripgrep | 2,208 | 111.8 MB | 3.0 MB | 2.7 MB | pgit (10%) | | flask | 5,516 | 167.3 MB | 6.1 MB | 5.5 MB | pgit (10%) | | prettier | 11,084 | 2.0 GB | 66.1 MB | 91.1 MB | git (38%) |
pgit outcompresses git on the majority of repositories while making the entire history SQL-queryable. It wins where most changes are incremental edits to source code. Git pulls ahead on repositories with heavy cross-file similarity between unrelated files.
Source: Hacker News










