Reputation: 2505
I have a clone of a git repository checked out that I use to have atomation collect period metrics (KLOC, etc.)
I collect these metrics once a week, but occasionally I want to go back into time and re-run the metrics (if I add a new metric, or something else in the system changes).
To checkout a particular point in time I use the following command:
git checkout `git rev-list -n 1 --before=2012-8-20 master` --force
But I find that the rev-list command does not keep up to date. New revisions that occur after the date I start using this process do not appear in the rev-list command. If I clone from scratch, I see the additional revisions, but I would prefer not to have to clone the entire repository each time.
Is there an option I am missing on rev-list to have it know all the latest revisions from the master branch?
Upvotes: 2
Views: 1112
Reputation: 2505
I think the deal here is that the revlist is not updated automatically relative to a remote master. Because of this, I need to add the following commands:
git checkout master # to go back onto the master branch
git pull # to update from the master
Now the rev list will be up to date, and I can accurately run:
git checkout `git rev-list -n 1 --before=2012-8-20 master` --force
Now the above command correctly works as a time machine so I can calculate my code metrics.
Upvotes: 1