How can I export every commit in git into my own numbered archive?
I started using git for version control for binaries (.ai and .indd). I was wondering how I would export each commit of one of these files (or the entire repo) so that then after that I would have a sequence of images that I could use to create a video like this moxie doxy that was generated from files saved as font (n), font (n ++) ....
so I think what I am trying to achieve is something like this:
Git archive -o export iterateOverAllCommits EXPORTS_TO (first commit) archive0001.zip, (second commit) archive0002.zip ...
After that, there is no problem with expanding / preparing files for video.
source to share
By combining git archive
and git rev-list
with a little bash, you can do this.
COUNT=0
for commit in `git rev-list --reverse HEAD`; do
git archive $commit --format=zip -o archive$COUNT.zip
COUNT=$((COUNT + 1))
done
git rev-list --reverse HEAD
prints the hashes of the commit starting at the first commit and ending at HEAD.
git archive $commit --format=zip -o archive$COUNT.zip
creates a zip archive of the commit specified by the commit hash from rev-list
.
Both rev-list
and archive
have a variety of options that can help you modify files that contain the information you need.
Using printf you can easily change the above value to zero.
source to share