On 22 Jun 11:05, Jenny Hopkins wrote:
On 21 June 2010 10:21, MJ Ray mjr@phonecoop.coop wrote:
Jenny Hopkins hopkins.jenny@gmail.com
Does anyone use GIT?
I want to know if one can use git-archive to retrieve a tarball snapshot of head revision at or before an instructed date. Google is not being my friend.
We use git extensively. I think if you use git-log -1 --until=DATE to get the commit number of the head revision at or before that date, then you could just give that as the main option to git-archive, but I've not tested that.
Thanks, Mark.
I'm boggling a bit from the man pages as to which commands have to be run from within a checked out git repository and which can allow a user to simply grab a tarballed snapshot as a one off. In my instance here. the gitweb page allows a user to see the revisions and click on a link to grab a tarball - no need to even have git installed: http://www.aleph1.co.uk/gitweb?p=yaffs2/.git;a=summary
This would translate in a script to: wget http://www.aleph1.co.uk/gitweb?p=yaffs2/.git;a=tree;h=5ea7d7c7d87b076ac17628...
I was hoping I could pass a date to something git-like that does the same sort of thing, if that makes sense. Or use wget with a date as per above..
OK - here's what you can use to generate a tar of a specified date...
GIT_DIR=/path/to/the/.git git archive --format=tar $(git rev-list -n1 --before="YYYY-mm-dd 23:59:59" master) | gzip -9 > /path/to/where/you/want/the/tar/created.tar.gz
That would be the last commit before 23:59:59 on the date YYYY-mm-dd.
Basically, what you're going is getting the commit id using git rev-list and passing that to the git archive command. You probably also want to use a --prefix on the archive command so that the .tar.gz gets nice paths in it.
Hope that helps,