using git to recreate historic builds

33 views
Skip to first unread message

John Vasileff

unread,
May 25, 2015, 12:03:30 PM5/25/15
to ceylo...@googlegroups.com
Just learned something useful about git that I thought I’d share.

For a while, I’ve been using commands like:

git checkout 'origin/master@{2015-03-26}’
git checkout 'origin/master@{7 hours ago}’

to recreate historic builds across multiple repositories.

But, as it turns out, the time specification in those commands refers to *the state of the branch in your local repository at that time*, and not necessarily commit timestamps. So, if you went a month without fetching `origin/master`, and then fetched, “1 hour ago” would yield the same result as “20 days ago”.

It may be useful to recreate *your* repository at a point in time. But it may also be confusing. Fortunately, there is a way to discover commits based on the commit timestamp, and checkout based on that:

git checkout `git rev-list -n 1 --before="2015-03-26" origin/master`
git checkout `git rev-list -n 1 --before="7 hours ago" origin/master`

This still isn’t perfect since not all commits are immediately pushed (there’s no way to recreate the state of *github’s* repository at a point in time). But it should work pretty well.

John

Gavin King

unread,
May 25, 2015, 12:05:58 PM5/25/15
to ceylo...@googlegroups.com
Hah! Thanks, that's very useful!
> --
> You received this message because you are subscribed to the Google Groups "ceylon-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ceylon-dev+...@googlegroups.com.
> To post to this group, send email to ceylo...@googlegroups.com.
> Visit this group at http://groups.google.com/group/ceylon-dev.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ceylon-dev/7C95B9F4-D702-4C36-A4E0-DD9036EBA5C2%40vasileff.com.
> For more options, visit https://groups.google.com/d/optout.



--
Gavin King
ga...@ceylon-lang.org
http://profiles.google.com/gavin.king
http://ceylon-lang.org
http://hibernate.org
http://seamframework.org
Reply all
Reply to author
Forward
0 new messages