git: how to retrieve all files as of a certain date

我相信这可以做到(?)(明确地说,它会很简单)。


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)


Use git log to determine a suitable revision to switch to, eg:

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.


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
链接地址: http://www.djcxy.com/p/48982.html

上一篇: 我是否需要在裸回购版上运行git gc?

下一篇: git:如何检索特定日期的所有文件