This is indeed fairly severe abuse of the tool. It would probably be better to figure out what is corrupting the original files. All Git will be really giving you here is content checksumming, which you can do outside Git ... or inside Git, with less-severe abuse, by using a data structure other than the usual chain of commits.
In other words, if you want to do this to learn how to use Git the wrong way :-) I think there is a "better wrong way". Here is my suggestion:
Make each commit on a new, orphan branch. You can do this with git checkout -b --orphan
or by using the "plumbing" tools git write-tree
and git commit-tree
.
Each branch is to contain one and only one commit. (If you are using the plumbing tools, you can use tags instead of branches.)
Then, to delete a backup (the whole thing), simply delete the branch (or tag) name.
Diagrammatically, instead of:
o--o--o--...--o--o <-- master
^ ^
| \
| the most recent
|
an hour ago, or yesterday, or whatever
your commits will be:
o <-- backup-20160508T101112.13
o <-- backup-20160508T131415.16
...
These names are more or less ISO-date-format, YYYYMMDDTHHMM.SS; but you may use any names that make the most sense to you.
Note that if two backups commit the same files, they re-use all the underlying Git "blob" objects, so two backups take basically the same space as one backup. Removing one of these two backups (by deleting the branch or tag name) has no effect since all those files are referred-to by the other backup.
If one file (xyz.txt
) is slightly different, Git will delta-compress it against another file (in any other commit) in Git's usual way: the commits need not be joined by parent/child relationships. Note that image and movie files rarely compress well in Git anyway (because they already compressed: information theory says that if the first compression was any good, the second attempt will not help).
Now let's say you decide you no longer need to back up file foo.jpg
. Just remove it: it will expire and be garbage-collected once the oldest backup is from "now". It's true that removed files will remain in older backups, but only for as long as you keep those backups.