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}'
This will get you the most recent commit before the desired date:
git log -n1 --before <date>
You could then just check out that commit (i.e. git checkout <sha1>
) and see the state of all files as of that time.
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}'
This will get you the most recent commit before the desired date:
git log -n1 --before <date>
You could then just check out that commit (i.e. git checkout <sha1>
) and see the state of all files as of that time.
0 commentaires:
Enregistrer un commentaire