In an attempt to gather some statistics about a Git repository, I’m looking for a way to do the following:
- For each commit, execute a command (ex;
du -h). - That command should run from the repository base directory “as it looked like” after the commit.
- The command would ideally have access to the commit hash and time stamp.
One application, expressed in quasi-Bash, would be to run
echo $HASH $TIME `du -hs --exclude=".git" . | awk '{ print $1; }'` >> ../sizeovertime
on all commits to get an idea of the growth of the repository.
(Somehow, it feels like it should be possible to use git filter-branch --tree-filter for this but that looks like a terrible hack to me.)
I don’t see how you could do this without checking out each commit, so that is going to take a while on a large repository.
Here’s how you could go about it with bash:
Warning: this will leave you in detached head state, on the oldest commit, which is not a nice place to be.