开发者

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

I'm sure this can be done (?) (in 开发者_如何转开发clearcase it would be quite simple).


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.


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)


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜