Command reference¶
Use db-git --help or db-git <command> --help for the complete option list.
Initialize¶
Useful options:
db-git init \
--database-url postgresql://user:password@localhost:5432/myapp \
--mode per-branch \
--strategy template \
--on-active-connections terminate
Skip hook installation:
Inspect State¶
Shared Mode Commands¶
Save the current branch database:
Restore the current branch database:
Save or restore a specific branch:
Per-Branch Commands¶
Create a branch database before checking out the branch:
Choose the source explicitly:
--from copies the source branch's existing database and records that branch as
its origin. The configured default branch selects the seed. Other sources must
have recorded ownership and an existing database, including recorded legacy
names. An unavailable explicit source produces an error; there is no fallback.
The command creates a database, without checking out or creating a Git branch.
Existing target databases are never overwritten.
Without --from, create retains its current-branch behavior: copy the current
branch's recorded database when available, otherwise use the seed. --from is
available only in per-branch mode.
Build a replacement from the seed database, retaining the previous database for recovery:
The default branch database cannot be reset because it is the seed for other branch databases.
Prune Deleted Branches¶
Preview stale snapshots or branch databases:
Remove stale snapshots or branch databases from active use:
PostgreSQL pruned data and MySQL shared snapshot archives are retained as recovery
copies. Use db-git recover to identify the prune operation, then
db-git recover <operation-id> --discard to release its retained storage.
SQLite files and MySQL database generations remain on disk or on the server;
pruning removes their ownership records and does not delete those databases.
See the SQLite and MySQL guides
before manually removing retained data.
Hook Management¶
Install or reinstall the checkout hook:
Remove the checkout hook:
Temporarily disable db-git in the current worktree without removing the hook:
You can also skip hook behavior for a single checkout:
Checkpoints and history¶
Use checkpoint, history, and restore --checkpoint to manage explicit
checkpoints. See checkpoint history for names, IDs,
retention, and integrity checks.
Applications, recovery, and diagnostics¶
run -- <command>launches your app with its database URL.recoverinspects and resolves operation journals.doctordiagnoses configuration and database issues.