简体   繁体   中英

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

我确信这可以做到(?)(在明文中它会非常简单)。

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM