展示HN:我的Postgres私有GitHub
Show HN: My Private GitHub on Postgres

原始链接: https://github.com/calebwin/gitgres

## GitGres:一个自托管的GitHub替代方案 GitGres是一个项目,旨在帮助团队构建私有、可定制的GitHub替代方案。它通过提供对成本、正常运行时间、延迟和一致性的更大控制,来解决GitHub的局限性。 与GitHub的云端方法不同,GitGres利用Postgres数据库存储*所有*Git数据——对象、引用、问题、PR等,从而消除了对磁盘的依赖,并允许进行可调整的性能优化。用户可以通过利用分层Postgres存储和缓存来优化成本,并通过选择首选的Postgres缓存来提高响应速度。GitGres本地运行或与代理共置,可完全控制一致性和吞吐量。 设置过程包括构建二进制文件、配置Postgres数据库、初始化模式,并使用引导令牌启动服务器以获取管理员访问权限。它通过智能HTTP支持标准Git命令(clone、push)、与`gh` CLI集成以及自定义远程助手。 目前,GitGres缺乏搜索、Actions、SSH支持和Web UI等功能,专注于核心Git功能。

Hacker News 新闻 | 过去 | 评论 | 提问 | 展示 | 招聘 | 提交 登录 展示 HN: 我的Postgres私有GitHub (github.com/calebwin) 7 分,calebhwin 发表于 20 分钟前 | 隐藏 | 过去 | 收藏 | 1 条评论 帮助 Mic92 8 分钟前 | 下一个 [–] 好主意。回复 考虑申请YC 2026年夏季项目!申请截止至5月4日 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

GitGres

GitGres is a starting point for private reimplementations of GitHub optimizied for individual teams' agent needs. GitHub is a fantastic site for sharing code and it is likely how you're viewing this if you're a human. GitGres exists to solve for a few issues:

  • Trading off cost for uptime. GitHub offers free code storage but less-than-stellar uptime. With GitGres, you have the flexibility to use a Postgres DBMS with tiered storage [1] to tune cost while maintaining uptime.
  • Trading off latency for cost. GitHub puts you at the mercy of current system load. With GitGres, just choose your favorite Postgres cache [2].
  • Trading off consistency for throughput. GitHub is a cloud service. If requests reach GitHub's servers out of order, bad things can happen. GitGres is a server backed by Postgres. It can run locally. It can run colocated with many agents. Consistency and throughput are fully tunable.

Everything - git objects, refs, packfiles, deltas, tokens, PRs, issues, comments, reviews, reactions, teams, orgs, events - lives in Postgres rows. The server holds nothing on disk.

# 1. Build (binaries land in ./target/release/{gitgres,git-remote-gitgres,gitgres-server}).
cargo build --release --bins

# 2. Have a Postgres reachable. e.g.
export GITGRES_DB='host=localhost user=postgres dbname=gitgres'

# 3. Apply the schema (idempotent).
gitgres init

# 4. Boot the server. The first --bootstrap-token mints an admin token tied
#    to user 'demo' that you can use to manage everything else through the API.
gitgres serve --listen 0.0.0.0:8080 --bootstrap-token "$(openssl rand -hex 32)"

# (For TLS:)
gitgres serve --listen 0.0.0.0:8443 \
              --tls /path/cert.pem /path/key.pem \
              --bootstrap-token TOKEN

gitgres serve env vars:

Var Default Purpose
GITGRES_DB Postgres conn string if --db not given
GITGRES_PUBLIC_URL https://gitgres.local Base URL the API returns in Repository.cloneUrl
GITGRES_WORKERS 8 HTTP worker threads
GITGRES_GQL_LOG unset If set, logs every GraphQL request body to stderr

Plain git (smart HTTP, v1 + v2):

git clone http://gitgres.host/owner/repo.git
git push http://demo:[email protected]/owner/repo.git main

gh CLI:

# Print a hosts.yml entry, drop into ~/.config/gh/hosts.yml:
gitgres gh-config --host gitgres.host --token TOKEN --user alice

# Or pipe a token into gh:
echo "TOKEN" | gh auth login --hostname gitgres.host --with-token

gh pr create / list / view / merge / comment / close / diff
gh issue create / list / view / comment / close
gh repo create / view / clone / fork / list
gh release create / list / view
gh label create / list / edit / delete
gh api /repos/owner/repo/...   # the entire REST surface

Custom remote helper (alternative to smart HTTP, also works):

git clone "gitgres::host=db.local user=u dbname=gitgres#owner/repo"

Currently, GitGres doesn't support search, actions/workflows/runs/secrets, SSH transport, webhooks, HTTP/2, web UI.

[1] https://www.alibabacloud.com/help/en/polardb/polardb-for-postgresql/cold-data-archiving/

[2] https://www.pgcache.com/

联系我们 contact @ memedata.com