Can I use repo to sync by date? (possible in git)

For example, I want to download the source as of March 1 at 3pm. I need a way to grab a specific base of CyanogenMod9 source. It would be nice to use a tag or commit ID, but the source is organized in several sub-repositories that don't have common tags. I'm thinking I could checkout by date. Suggestions?


Looks like I'll have to use repo forall. This requires sync'ing everything first (can't checkout older code until repository is fully downloaded).

repo forall -c 'git checkout `git rev-list --all -n1 --before="2012-03-01 15:00"`'
  • 2
    This assumes that the manifest has not changed at all. If the current manifest is different than the manifest at the date of interest, all sorts of problems could bite you --- different branches, paths, file copy commands, etc. – Jeremy Frank Aug 8 '17 at 20:18
  • You really should not be using --all here. This will list commits from any branch. Most certainly, you don't want to move away from the current branch. You only want to go to the first commit in the history of the current branch, which meets the "before" requirement: repo forall -c 'git checkout `git rev-list -n1 --before="2012-03-01 15:00"` HEAD' – schlimmchen Mar 20 '18 at 19:48
  • @schlimmchen I think your last back-quote is misplaced, i think "HEAD" should be within the backquotes too. – skyking Aug 6 '18 at 11:14
  • @skyking Yes, obviously you are right! repo forall -c 'git checkout `git rev-list -n1 --before="2012-03-01 15:00" HEAD`' – schlimmchen Aug 6 '18 at 13:27

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.