12

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 stands with Ukraine
  • 25,310
  • 18
  • 114
  • 149
mahemoff
  • 41,502
  • 34
  • 146
  • 213

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,020
  • 8
  • 20
  • 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