13

How can I check out a git repository using time notation such as "3 days ago", "12 months ago", etc?

Note this related question only concerns the local repo, but I want to inspect the remote repo.

Zoe
  • 27,060
  • 21
  • 118
  • 148
mahemoff
  • 44,526
  • 36
  • 160
  • 222

1 Answers1

14

git checkout by date gives me

git checkout `git rev-list -n 1 --before="3 days ago" master`
Community
  • 1
  • 1
Thorsten Staerk
  • 1,114
  • 9
  • 21
  • The OP wanted to explicitly inspect the remote rather than the local master branch. – mockinterface Dec 27 '13 at 13:16
  • @mockinterface Unlike your answer, this one will (mostly) do the right thing if you replace "master" by "origin/master". –  Dec 27 '13 at 13:17
  • 1
    Of course, but the OP already has in mind the notation that he wants to use, and the answer should explain how to apply it to a remote branch. At the very least it should indeed use origin/master instead of master, and explain that fetching is necessary. – mockinterface Dec 27 '13 at 13:24
  • This worked for me, and I edited the answer to include `3 days ago` notation. Thanks for pointing it out @hvd. – mahemoff Dec 27 '13 at 18:23