<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/git-in-postgres-ba7yln5mf" -->

---
title: Git in Postgres | daily.dev
description: An exploration of storing git repositories inside PostgreSQL instead of the filesystem. The author built gitgres, a ~2,000-line C library implementing...
canonical: https://daily.dev/posts/git-in-postgres-ba7yln5mf
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Git in Postgres | daily.dev
og:description: An exploration of storing git repositories inside PostgreSQL instead of the filesystem. The author built gitgres, a ~2,000-line C library implementing...
og:url: https://daily.dev/posts/git-in-postgres-ba7yln5mf
og:image: https://api.daily.dev/og/posts/Ba7yln5MF.png
og:image:alt: Git in Postgres
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Git in Postgres

**[Lobsters](https://daily.dev/sources/lobsters)** · 8 min read · 80 upvotes · 3 comments

## Summary

An exploration of storing git repositories inside PostgreSQL instead of the filesystem. The author built gitgres, a ~2,000-line C library implementing libgit2's object and ref database backends against Postgres via libpq. The git data model maps to just two tables (objects and refs), enabling SQL queries that join commit history with application data like issue trackers. The post argues this approach could simplify self-hosted forge deployments (targeting Forgejo/Gitea) by eliminating the split between a Postgres-backed web app and filesystem-based bare repos, enabling unified backups with pg_dump, row-level security for multi-tenancy, and NOTIFY-based push events. Storage overhead from lack of delta compression is acknowledged as a real trade-off, but the author argues operational simplicity outweighs it for small instances.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://nesbitt.io/2026/02/26/git-in-postgres.html>

## Community discussion

Top comments from developers on daily.dev.

**@andrewvaz** · 1 upvotes

> I always wondered if it would be faster to use a database such as Postgres as the back-end repository instead of the filesystem. Interesting to know about the pros and cons.

**@matj** · 0 upvotes

> yo gitlab does it, doesn't it ?

**@khauma** · 0 upvotes

> Interesting read

## Similar posts on daily.dev

- [pgit: What If Your Git History Was a SQL Database?](https://daily.dev/posts/pgit-what-if-your-git-history-was-a-sql-database--k2mbbtlm1) · Hacker News · 44 upvotes · 0 comments
- [Just Use Postgres\!](https://daily.dev/posts/just-use-postgres--c90ppdw4c) · Vlad Mihalcea · 255 upvotes · 24 comments
- [Database Branching in Postgres: Git-Style Workflows with Databricks Lakebase](https://daily.dev/posts/database-branching-in-postgres-git-style-workflows-with-databricks-lakebase-hdnh9bdho) · databricks · 23 upvotes · 0 comments

---

Tags: [#forgejo](https://daily.dev/tags/forgejo), [#git](https://daily.dev/tags/git), [#postgresql](https://daily.dev/tags/postgresql)

[View this post on daily.dev](https://daily.dev/posts/git-in-postgres-ba7yln5mf)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Git in Postgres","url":"https://daily.dev/posts/git-in-postgres-ba7yln5mf","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/git-in-postgres-ba7yln5mf"},"datePublished":"2026-02-26T15:13:25.353Z","dateModified":"2026-07-30T02:12:49.225Z","description":"An exploration of storing git repositories inside PostgreSQL instead of the filesystem. The author built gitgres, a ~2,000-line C library implementing...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/416572ca2b211e96c4c4b92af22d1ec7?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/416572ca2b211e96c4c4b92af22d1ec7?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"Lobsters","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Lobsters","logo":"https://media.daily.dev/image/upload/s--tl8v_Fku--/f_auto,t_logo/v1698841318/logos/lobste.jpg","url":"https://daily.dev/sources/lobsters"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/git-in-postgres-ba7yln5mf","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":80},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"forgejo,git,postgresql","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Lobsters","item":"https://daily.dev/sources/lobsters"},{"@type":"ListItem","position":3,"name":"Git in Postgres"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/git-in-postgres-ba7yln5mf","comment":[{"@type":"Comment","text":"I always wondered if it would be faster to use a database such as Postgres as the back-end repository instead of the filesystem. Interesting to know about the pros and cons.","datePublished":"2026-02-27T14:26:37.310Z","url":"https://daily.dev/posts/Ba7yln5MF#c-XtOaT5Q0N","author":{"@type":"Person","name":"Andrew Vaz","url":"https://daily.dev/andrewvaz","image":"https://lh3.googleusercontent.com/a/ACg8ocJ6KlvjV2AlNuC438nFoPIx826S9B2Cfv3V5zjmCDWwCeTcke0=s96-c"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":1}},{"@type":"Comment","text":"yo gitlab does it, doesn’t it ?","datePublished":"2026-03-11T13:13:41.907Z","url":"https://daily.dev/posts/Ba7yln5MF#c-XnHel4zQR","author":{"@type":"Person","name":"MateuszJ","url":"https://daily.dev/matj","image":"https://lh3.googleusercontent.com/a/ACg8ocJFNTgJi4N7H0B1pB5tzUpZWfMQErUQ8qkWuksxaQLTPUIV5g=s96-c"}},{"@type":"Comment","text":"Interesting read","datePublished":"2026-02-26T20:19:33.603Z","url":"https://daily.dev/posts/Ba7yln5MF#c-44xnVIjZt","author":{"@type":"Person","name":"Kahlil Wallace","url":"https://daily.dev/khauma","image":"https://media.daily.dev/image/upload/s--QvppE9Ip--/f_auto/v1767378558/avatars/avatar_7eQFeSQRDx0muV3n92gxT?_a=BAMAK+ZW0"}}]}
```

