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
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}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With