5

I have add *.sqlite3 to my .gitignore_global file:

When I run git status in my terminal there still have db.sqlite3 listed as modified:

How can I ignore my SQLite file?

1
  • 1
    From your screenshot it doesn't actually look like you've added that entry to the ignore file. Commented Sep 17, 2017 at 14:10

2 Answers 2

20

I see three issues here:

  1. .gitignore_global isn't a standard Git ignore file. If you haven't told Git about it it will have no effect. Something like git config --global core.excludesfile <file> can be used to add a global ignore file.

  2. Your screenshot actually doesn't show *.sqlite3 in your ignore file. You'll have to add that, or a pattern like it.

  3. Finally, and most importantly, Git's ignore system doesn't prevent tracked files from being modified. It only prevents files from being tracked in the first place. Your screenshot shows db.sqlite3 as being modified, not new.

    You can tell Git to stop tracking the file with git rm --cached db.sqlite3, then commit. This will leave the file in place, but remove it from the repository. Once that's done, and the previous two issues have been dealt with, your file should be ignored.

Sign up to request clarification or add additional context in comments.

Comments

-1

I tried this command, and it did ignore changes in db.sqlite3:

git update-index --assume-unchanged db.sqlite3

3 Comments

Sorry it worked for me perfectly, and it's well ignored in all commits
It might look like it worked for you perfectly. That's one of the reasons it's such a bad idea. It seems like it's doing what you want, but it isn't. That quote is from the long-time maintainer of Git, and I strongly suggest you follow his advice. It's very likely that db.sqlite3 shouldn't be in your repository at all. In that case it should be removed, e.g. with git rm --cached db.sqlite3, and that change should be committed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.