Skip to main content

graft init

Initialize Graft on a target database container. This is the first command you run — it bridges the container’s Docker volume to the host filesystem and sets up the Graft project structure.

Usage

Behavior

  1. Inspects the target container (image, env, ports, network, volumes)
  2. Prompts you to select which Docker volume contains the database data
  3. Stops the container
  4. Copies data from the Docker volume to ~/.graft/<container>/branches/main/ via an ephemeral Alpine runner
  5. Sets up the graft.db SQLite DAG store and objects/ directory
  6. If --bind, recreates the container with a host bind mount
  7. Starts the container
  8. Saves the state to config.json

Flags

Examples

Interactive Init

Prompts you to select which volume contains the database data.

With Explicit Volume

With Bind Mount

In bind mount mode, Graft takes full control of the container lifecycle. After init, the container uses a host bind mount instead of a Docker volume.

Output

Modes

In snapshot mode, graft commit bridges from the Docker volume to the host. In bind mode, the container’s data lives directly on the host and no bridging is needed.

Exit Codes