Skip to main content

Git-like tool backed by Neo4j

Project description

neogit

PyPI Python versions CI Docs License

A Git-like tool for filesystems, backed by a Neo4j graph and pluggable object storage.

Neogit takes content-addressed Merkle-tree snapshots of a directory tree and stores them in two places:

  • Neo4j — the graph: commits, branches, trees, blobs, and their relationships
  • Object storage — the bytes: file contents addressed by their SHA-1 (local filesystem, MinIO, or S3 via Apache Libcloud)

This split makes filesystem state queryable as a graph (Cypher over commits, diff trees, walk history) while keeping file contents in cheap blob storage.

Neo4j Browser showing a neogit Merkle tree with Branch, Commit, Tree, and Blob nodes

Where it's used

  • CLI tool — capture and diff filesystem snapshots from the command line
  • Python library — embed the Merkle model and Neo4j layer in your own pipeline. For example, OSWatcher uses neogit as the storage foundation, and downstream projects build analysis plugins (filetype detection, symbol extraction, syscall tracing, …) on top of the Commit / PluginRun graph

Quickstart

Requirements: Python 3.10+, Docker, and Git. Neogit uses local object storage by default, so the minimal setup only needs Neo4j.

pipx install neogit
# or: python -m pip install neogit

# Start a local Neo4j database for the demo. Auth disabled is for local testing only.
docker run --rm --name neogit-neo4j \
  -p 7474:7474 -p 7687:7687 \
  -e NEO4J_AUTH=none \
  neo4j:5.26

In another terminal, snapshot a real project checkout:

git clone --depth 1 https://github.com/psf/requests.git neogit-demo-root

neogit init
neogit commit first-snapshot -r ./neogit-demo-root

Open the Neo4j browser at http://localhost:7474 and run:

MATCH (c:Commit)-[r]->(t:Tree) RETURN c, r, t LIMIT 25

CLI overview

neogit init                                    # initialize database constraints
neogit commit <name> -r <path>                 # snapshot a directory on the default branch
neogit diff <old_hash> <new_hash>              # compare two filesystem snapshots
neogit branch <name> <commit_hash>             # create a branch pointing at a commit hash

See docs/reference/cli.md for the full reference.

Use as a library

from pathlib import Path
from neogit.service import Neogit

git = Neogit()
git.init()
commit_hash = git.commit("snapshot-1", Path("/path/to/capture"))

The graph model (Commit, Branch, Tree, Blob, PluginRun) is exposed under neogit.model for downstream tools that want to attach their own nodes — see docs/reference/data-model.md.

Documentation

Full documentation lives under docs/ and follows the Divio framework:

  • Tutorial — your first snapshot in 5 minutes
  • How-to guides — recipes for specific tasks (MinIO, S3, diffs, embedding the library)
  • Reference — CLI flags, config keys, data model
  • Explanation — design rationale, Merkle layout, why Neo4j

To preview the docs locally:

poetry install --with docs       # one-time, installs mkdocs into the venv
poetry run poe docs_serve        # equivalent to: poetry run mkdocs serve

Development

poetry install
poetry run poe ccode      # fmt + lint + type-check
poetry run poe test       # full test suite

See docs/how-to/contributing.md for the full dev workflow.

License

Licensed under the Apache License 2.0. You're free to use, modify, and distribute neogit, including commercially, provided you preserve the copyright and license notices (see NOTICE).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

neogit-0.15.0.tar.gz (41.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neogit-0.15.0-py3-none-any.whl (58.4 kB view details)

Uploaded Python 3

File details

Details for the file neogit-0.15.0.tar.gz.

File metadata

  • Download URL: neogit-0.15.0.tar.gz
  • Upload date:
  • Size: 41.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.15 Linux/6.17.0-1015-azure

File hashes

Hashes for neogit-0.15.0.tar.gz
Algorithm Hash digest
SHA256 a2f2643ee9e961e95f5cad085844921830377260c3d8d1fca8f19d205bc3a18d
MD5 7dd4d58701a1458a6c9c3e2c9ab0e506
BLAKE2b-256 f0fa5a2cfe92991f537cc7ffd569050baa14240ef987ce0ccb9134b04cd7bd19

See more details on using hashes here.

File details

Details for the file neogit-0.15.0-py3-none-any.whl.

File metadata

  • Download URL: neogit-0.15.0-py3-none-any.whl
  • Upload date:
  • Size: 58.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.11.15 Linux/6.17.0-1015-azure

File hashes

Hashes for neogit-0.15.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9784c763b4be1e662ff8b1c557cfa86af86725b7f04cca7faee46049da7e5fdb
MD5 0e3f566650335c164d0817d0a832f897
BLAKE2b-256 d7f14c6268859918e64ba7366016b2236b882908e41307b5776e95ea119c7938

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page