0

What I'm trying to do is to version a file without ever pushing it to github, is it something I can do ?

Context : For instance, I have a local database for dev (Django) which is SQLite3 which creates a file "db.sqlite3". I don't want this file to be on github, but I'd like to be able to reset it to previous version if I mess with the migrations for example.

Maybe they are better ways than git, I'm open to suggestions.

Thank you !

  • You could gitignore the SQLite file and "version" the database by [dumping the data](https://docs.djangoproject.com/en/3.2/ref/django-admin/#dumpdata) into fixtures. But I find it hard to imagine why you would want to do this because you could simply rollback your db to a previous migration. – Scratch'N'Purr Aug 17 '21 at 09:41

1 Answers1

0

As far as I’m aware a file is either tracked (included in commits and pushes) or ignored. There isn’t a middle ground and I’m not sure there needs to be.

https://git-scm.com/book/en/v2/images/lifecycle.png

If you can isolate the file within its own directory- create a separate git repo for that directory and don’t have a remote associated with it.

Maintain git repo inside another git repo

Furthermore you could create an automatic schedule for git commits (using cron for example) so you can do point in time recovery for that directory.

If you can’t move the file then schedule a backup of the file to another folder and commit the backup to a different local repo.

Copy SQLite database to another path

shift
  • 76
  • 4
  • Nice suggestion ! But what if I can't isolate it ? It's basically at the root of my project, might have to fiddle with settings and that would impact my colleague as well. – Benjamin_Mourgues Aug 17 '21 at 09:24
  • Create a directory outside your project and symlink to the file – fredrik Aug 17 '21 at 09:35