Version and backup a Git repository
What is this?
This is a small tool that does git fetch then writes down all ref updates in a SQLite3 database. It also creates refs to make sure no commit gets garbage collected.
If the remote repository gets force-pushed to, some commits might get lost. There will also be no evidence in the Git log that such destructive changes happened. It is also possible for a commit to be created but pushed much later, or branches can get renamed; none of this appears in the Git log either.
This tool will allow you to get a clear picture of what happened, never lose a commit, and quickly get a snapshot of a repository at a specific point in time. It is therefore more suitable for backups than a mirror.
Doesn’t the reflog do all that?
This is indeed similar to Git’s built-in reflog, except that the reflog isn’t aware of branch renames, and a branch’s reflog gets deleted with the branch.
It is also local, so you wouldn’t be able to read the reflog of a remote repository.
How to use
First, create a bare repo:
$ mkdir my-repo-backup && cd my-repo-backup $ git init --bare
Set up one (or multiple) remotes to fetch from:
$ git remote add origin https://github.com/remram44/doublegit.git
Then simply run doublegit once in a while:
$ python3 doublegit.py /path/to/my-repo-backup
You can then query gitarchive.sqlite3 for branch updates or for the position of the branches at a given point in time.
I think it would be cool if this tool could record GitHub/GitLab/… API events too; things like issues/merge requests/comments.
It could also automatically backup all your starred repos.
This also doesn’t support tags yet.
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|Filename, size||File type||Python version||Upload date||Hashes|
|Filename, size doublegit-1.2-py2.py3-none-any.whl (6.4 kB)||File type Wheel||Python version py2.py3||Upload date||Hashes View|
|Filename, size doublegit-1.2.tar.gz (6.8 kB)||File type Source||Python version None||Upload date||Hashes View|
Hashes for doublegit-1.2-py2.py3-none-any.whl