13
votes

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

3
Note: In distributed systems (like Git) the recorded dates and times may not be 100% reliable or accurate since they may be recorded on a myriad of machines. Hopefully most machines are reasonably close to the “real time”, but there may be oddball outliers lurking in the network of contributors. - Chris Johnsen

3 Answers

5
votes

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)

14
votes

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.

3
votes

first, you have to get the string that identify the commit:

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

it prints the string (for instance XXXX), copy it and do this command:

git checkout XXXX