跳转到内容

历史与恢复

Graft 使用 Git-like 模型:

worktree -> index -> commit

SQLite transaction 更新数据库状态;Graft commit 记录哪些 snapshot 和文件 artifact 属于一个应用状态版本。

Terminal window
graft status
graft add --all
graft commit -m "save checkpoint"

查看:

Terminal window
graft log
graft log --json
graft show HEAD
graft show --json HEAD
Terminal window
graft branch feature/search
graft switch feature/search
graft switch -c experiment main

切换分支会把目标 commit 中的 SQLite snapshot 和文件 artifact materialize 到 worktree。

HEAD 恢复 worktree path:

Terminal window
graft restore --source HEAD -- data.sqlite

从旧 revision 恢复:

Terminal window
graft restore --source HEAD~1 -- attachments/report.pdf

取消 stage:

Terminal window
graft restore --staged -- data.sqlite
graft restore --staged --all --kind sqlite_database
Terminal window
graft checkout HEAD~1
graft checkout HEAD~1 data.sqlite

Reset:

Terminal window
graft reset --soft HEAD~1
graft reset --mixed HEAD~1
graft reset --hard HEAD~1

--hard 会丢弃 staged 和 unstaged worktree changes,只在明确需要时使用。

Terminal window
graft tag v0.1
graft tag -a v0.1 -m "first checkpoint"
graft tag
graft tag -d v0.1