Adding file mask to .gitignore
does not do anything by itself, and certainly does NOT delete file from remote repository (read more here).
In general, it is really bad idea to store SQLite databases under source control (including git). Best solution for this is to create script that creates template database if necessary. This script can look like this:
database.sql:
BEGIN TRANSACTION; -- wrap everything into one transaction
-- create tables, always use NOT EXISTS:
CREATE TABLE IF NOT EXISTS items (
item_id INTEGER AUTOINCREMENT PRIMARY KEY,
item_name VARCHAR(32)
);
-- create indexes, always use NOT EXISTS:
CREATE INDEX IF NOT EXISTS items_item_name ON items (item_name);
-- add more CREATE TABLE and/or CREATE INDEX statements...
COMMIT;
Then you can execute this script using following command:
sqlite3 -init database.sql database.db ""
If you execute it first time, database.db
would be created if it did not exist. If you execute it second time, nothing will happen. But, you can decide later to add more indexes or tables into your database.sql
(which would be under source control), and executing it later would add missing objects into your database.