db-git¶
Keep your database in sync with your Git branches.
db-git connects your local database workflow to Git. Switch branches, try a
migration, or review a feature with the database state that belongs to that work.
The checkout hook handles switching; db-git run connects your application to the
selected database.
Choose your database¶
| Database | Modes | Strategy | Guide |
|---|---|---|---|
| PostgreSQL | Shared and per-branch | template, pgdump |
PostgreSQL |
| MySQL 8.0 / 8.4 | Shared and per-branch | mysqldump |
MySQL |
| SQLite | Per-branch | Online backup | SQLite |
Use local development databases. Each engine has different connection, privilege, and recovery requirements; read its guide before initializing.
Find your workflow¶
- New to db-git? Follow your first database branch.
- Working on several branches? Set up Git worktrees.
- Trying a migration? Create a checkpoint in shared mode.
- Connecting an application? Learn how
db-git runselects its URL. - Something failed? Start with doctor and recovery.
- Looking up an option? Browse commands and configuration.
How switching works¶
In shared mode, db-git saves the database for the branch you leave and restores the destination branch's snapshot when one exists. In per-branch mode, each branch has its own database and db-git creates or selects it on checkout.
Restart your application through db-git run -- <command> after switching.
An already-running process keeps its original connection.
Database changes use staged replacements and recovery journals. A checkout still completes if database handling fails; inspect the failure before continuing work. See recovery for retained copies and interrupted operations.