John Vasileff
unread,May 25, 2015, 12:03:30 PM5/25/15Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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