Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can I retrieve version of file from git for a given date?

Tags:

git

date

version

I need to retrieve the version of some file in my git repository which was the last commit before a date. For example, my date is 2013-03-08 and so I want to the version of the file committed on 2013-03-07 or before.

I can use a command like git show HEAD~<REVISION-NUM>:foo/bar/myfile.c but I have to figure out what <REVISION-NUM> is for my date. Moreover, if I need to retrieve multiple files for the same date, their <REVISION-NUM>s might be different.

So is there a command that would allow me to specify the date directly

like image 646
I Z Avatar asked Jun 04 '13 19:06

I Z


1 Answers

You can do it with rev-parse

git help rev-parse for details e.g.

git checkout 'master@{2013-06-01}'
git checkout 'master@{yesterday}'
git checkout 'master@{5 days ago}'
like image 167
parkydr Avatar answered Sep 30 '22 03:09

parkydr