Skip to content

Instantly share code, notes, and snippets.

@tyoc213
Last active August 28, 2020 04:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tyoc213/3e822faab9032d152cb3e8c057f88024 to your computer and use it in GitHub Desktop.
Save tyoc213/3e822faab9032d152cb3e8c057f88024 to your computer and use it in GitHub Desktop.
checkout by date on HEAD

https://www.endpoint.com/blog/2014/05/19/git-checkout-at-specific-date

git checkout `git rev-list -1 --before="Jan 17 2020" HEAD`

You only need a little change if you hit the limit of reflog (the date you cloned the repo or 90 days a go of history it seems from other notes)

git checkout `git rev-list -1 --before="Jan 17 2020" HEAD`

And you can also use

git checkout `git rev-list -1 --before="Jan 17 2020 8:06 UTC-8" HEAD`

it will checkout the previous commit related to the date or the date-time you enter, see that you can use modifiers for the date, I guess if you dont use UTC+-N it just uses UTC time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment