导出 SQLite 文件
Graft 把 SQLite 历史存为 snapshot,但可以 materialize 和 export 普通 SQLite 数据库文件。
Worktree Materialization
Section titled “Worktree Materialization”默认情况下,commit、checkout、switch、pull 和 merge-continue 后,Graft 会把 tracked SQLite snapshot 写回 worktree 的数据库路径:
project/ data.sqlite .graft/data.sqlite 是普通 SQLite 文件,可被标准工具读取。
Export Snapshot
Section titled “Export Snapshot”导出当前 worktree database state:
graft export --output data.inspect.sqlite data.sqlite导出指定 revision:
graft export --source HEAD --output data.head.sqlite data.sqlitegraft export --source HEAD~1 --output data.previous.sqlite data.sqlite导出的文件是普通 SQLite 数据库,不再连接当前 Graft volume。
使用外部 SQLite 工具
Section titled “使用外部 SQLite 工具”普通 SQLite 连接是默认写入方式。提交 SQLite transaction 后直接 stage:
sqlite3 data.sqlite "INSERT INTO notes(body) VALUES ('external edit');"graft add data.sqlitegraft commit -m "import external edit"graft add 使用 SQLite online backup 捕获一致的 committed state,包括已提交的
WAL frames,不需要手动 checkpoint,也不会修改源数据库。随后它只把相对
staged/HEAD 基线发生变化的 4 KiB Graft storage chunks 写入存储,这个粒度与物理
数据库的 SQLite page size 无关。
需要 live page-storage 时可以显式选择 vfs=graft,但它是可选数据面,不承载
repository 命令。
禁用 Materialization
Section titled “禁用 Materialization”[worktree]materialize_sqlite = true默认是 true。只有明确想要 volume-only database path 的集成才应设为
false。