Git: checkout by date

Sometimes it's handy to checkout a branch based on a point in time.

git checkout master@{2009-07-27 13:37}

will not work, because it uses the reflog (which expires after some time).

The trick (as found on Nabble) is to lookup the revision on a certain date and check out that revision. This can be done in a single command:

git checkout `git rev-list -n 1 --before="2009-07-27 13:37" master`