Skip to content

Repository files navigation

git-rest

Go ReferenceCIGo Report CardAsk DeepWiki

Lightweight REST API server for reading and writing files in a git repository. Auto-commits and pushes on writes, periodic pull keeps the local clone in sync.

Where this fits in the bigger picture

This service is the vault writer in the bborbe task / agent pipeline. agent's task/controller calls git-rest over HTTP to create / update / delete the markdown task files that materialize Kafka task.CreateCommand events into an Obsidian vault git remote.

git-rest itself knows nothing about tasks, vaults, or Kafka — it's a generic HTTP-over-git CRUD service. Any consumer wanting an HTTP write-path into a git repo can use it.

Full system map: recurring-task-creator/docs/system-map.md.

Use Cases

  • Expose a git repo to non-git clients (HTTP-only consumers, agents, K8s pods)
  • Serve a vault/wiki/notes repo over HTTP without a database or web app
  • Multi-instance deploys: one git-rest per repo, sharing nothing but the remote

Features

  • File CRUD over HTTP — GET, POST, DELETE on /api/v1/files/{path}
  • Glob-based file listing
  • Auto-clone on startup if --git-remote-url is set and --repo is empty
  • Auto-init local-only repos when no remote URL is configured
  • Periodic git pull to stay in sync with the remote
  • Auto git add + commit + push on every write/delete
  • Optional SSH key + git author config
  • Health and readiness endpoints (readiness reflects git status)
  • Prometheus metrics on /metrics

Quick Start

# local repo, no remote (file CRUD only)
git-rest --repo /tmp/my-repo --listen :8080
# remote repo, auto-clone over SSH
git-rest \
--repo /data \
--listen :8080 \
--git-remote-url git@github.com:owner/repo.git \
--git-ssh-key /ssh/id_ed25519 \
--git-user-name git-rest \
--git-user-email git-rest@example.com \
--pull-interval 30s

Configuration

All flags can be set as environment variables.

FlagEnv VarRequiredDefaultDescription
--listenLISTENyes:8080HTTP listen address
--repoREPOyesPath to git repository on disk
--pull-intervalPULL_INTERVALno30sPeriodic git pull interval
--git-remote-urlGIT_REMOTE_URLnoRemote URL to clone on startup (omit for local-only)
--git-ssh-keyGIT_SSH_KEYnoPath to SSH private key for git operations
--git-user-nameGIT_USER_NAMEnoGit author name for commits
--git-user-emailGIT_USER_EMAILnoGit author email for commits
--sentry-dsnSENTRY_DSNnoSentry DSN for error reporting
--sentry-proxySENTRY_PROXYnoHTTP proxy for Sentry

Build metadata (set via build flags):

FlagEnv VarDefault
--build-git-versionBUILD_GIT_VERSIONdev
--build-git-commitBUILD_GIT_COMMITnone
--build-dateBUILD_DATE

Bootstrap Modes

git-rest decides what to do at startup based on --git-remote-url and the state of --repo:

Remote URL--repo/.git existsAction
setnogit clone into --repo
setyesuse existing repo, periodic pull
emptynogit init empty repo, no push/pull
emptyyesuse existing repo, no push/pull

Local-only mode (no remote) skips all push/pull operations — useful for testing or single-node deployments.

Documentation

License

BSD-2-Clause

About

Lightweight REST API for reading and writing files in a git repository. Auto-clone, periodic pull, auto-commit + push on every write.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages