Skip to content

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.

Get started Choose a mode

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

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.

Project

Source code · Issues · Release notes · MIT license