tags:

views:

48

answers:

2

I'm sure this can be done (?) (in clearcase it would be quite simple).

+3  A: 

Don't forget file timestamp are not recorded in a DVCS like Git.
Only commit timestamp are there, and you can checkout easily a commit from a certain date.

git checkout master@{1 month 2 weeks 3 days 1 hour 1 second ago}

(Note: such a checkout would give you a detached HEAD)


In ClearCase, this is easy provided you set the "preserve file time" option to true.
(if not, you actually record the checkin time of each file, which is a bit like the Git commit timestamp, except for every files)

VonC
Ok, but there's an additional complication. My repository is a clone of a remote repository. When I give a date, it says that the log only goes back to the date when my repository was cloned. How can I make use of the history of the remote repository?
c-urchin
@steve: by using the remote refspec instead of a local one. See http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html#_specifying_revisions: `git checkout /refs/remotes/master@{...}`
VonC
fatal: '/refs/remote/master@{2010-06-04}' is outside repository
c-urchin
@steve: true, I don't have yet the right syntax. Still looking.
VonC
The `ref@{time}` syntax uses the reflog. Reflogs are local. That is why steve's log only goes back to the date it was cloned.
Chris Johnsen
+1  A: 

Use git log to determine a suitable revision to switch to, e.g.:

git log --since='2010-04-01' --until='2010-04-02'

This will show all the commits on 2010-04-01, so just pick the one that corresponds to the instant you want the files for, and note its commit id. Then just use git checkout COMMIT-ID to switch the workspace to that commit. This will detach your workspace (HEAD) from the current branch, use git checkout master to return.

araqnid