App-State Walkthrough
This walkthrough tracks a small app data directory: one SQLite database, one JSON config file, and one attachment. It shows the everyday shape Graft is designed for. You can rehearse the same concepts in the browser Playground before running the local commands below.
Create App State
Section titled “Create App State”mkdir graft-walkthroughcd graft-walkthroughgraft init
graft sql --db data.sqlite "CREATE TABLE docs(id TEXT PRIMARY KEY, title TEXT, attachment TEXT);"graft sql --db data.sqlite "INSERT INTO docs VALUES ('doc-1', 'Proposal', 'attachments/proposal.txt');"
mkdir -p attachmentsprintf 'proposal draft\n' > attachments/proposal.txtprintf '{ "theme": "light" }\n' > settings.jsonStage and commit everything:
graft status --jsongraft add --allgraft commit -m "seed app state"That commit records one coherent state:
data.sqlitesettings.jsonattachments/proposal.txtMake A Branch
Section titled “Make A Branch”graft switch -c rewrite-titlegraft sql --db data.sqlite "UPDATE docs SET title = 'Updated Proposal' WHERE id = 'doc-1';"printf 'proposal draft v2\n' > attachments/proposal.txtgraft diff --rows HEAD data.sqlitegraft add --allgraft commit -m "rewrite proposal"Switch back:
graft switch maingraft sql --db data.sqlite "SELECT id, title, attachment FROM docs;"cat attachments/proposal.txtGraft materializes the branch’s committed SQLite snapshots and files into the worktree as you switch.
Merge The Branch
Section titled “Merge The Branch”graft merge rewrite-titlegraft statusIf the changes are compatible, Graft can stage the merge result. If not, inspect conflicts:
graft conflicts --jsongraft resolve --theirs data.sqlitegraft merge --continue -m "merge rewrite"SQLite conflicts can include row-level analysis. File artifacts use conservative file-level resolution.
Sync Through A Local Remote
Section titled “Sync Through A Local Remote”Use a filesystem remote for a local smoke test:
mkdir -p /tmp/graft-remotegraft remote add origin fs:///tmp/graft-remotegraft push origin mainClone elsewhere:
mkdir ../graft-clonecd ../graft-clonegraft clone fs:///tmp/graft-remote maingraft sql --db data.sqlite "SELECT id, title FROM docs;"You now have the same app-state history in another worktree.