Skip to content

Instantly share code, notes, and snippets.

@antillean
Created March 8, 2016 13:23
Show Gist options
  • Save antillean/d2237538b76ff247abcf to your computer and use it in GitHub Desktop.
Save antillean/d2237538b76ff247abcf to your computer and use it in GitHub Desktop.
Git: get version of file at date
## The following checks out a file as it was on the current branch NUM_DAYS days ago.
## See manual page on gitlog for more date info: https://git-scm.com/docs/git-log
## (That includes info on the other ways of specifiying a date.)
git checkout `git log -n1 --before="${NUM_DAYS} days ago" --format="%H" path/to/file` path/to/file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment