GitHub

layout page
title `git diff` Support for SQLite Databases
description In case there's literally anyone else in the world other than me that needs it.
published_at Fri Jan 12 23:02:36 PDT 2024

The following teaches git how to convert an SQLite database into text that can be usefully diffed:

# .gitconfig / .git/config
[diff "sqlite3"]
    binary = true
    textconv = echo .dump | sqlite3

All that's left is teaching git how to recognize SQLite files. I'm not aware of any way to teach it about magic bytes or the file command1 so I've resorted to pattern matching:

# .gitattributes
*.db diff=sqlite3

(originally)

Footnotes

  1. Please write in if you do!

Read the original on github.com ↗