I wanted to generate some visualizations of our project’s growth, so I decided to put together a little shell script that looked at the output from git log to spit out some metrics.
So git-iterate was born: run anything through your entire project’s history, and get the results in something easily converted into a beautiful chart!
It does that by running git-reset --hard $COMMIT for every commit in the repository, and then calling the script given to it as the first argument. It passes the commit ID to the script too, so this:
git-iterate echo
…will generate a list of all your commit IDs, most recent last.
The code is on GitHub, as usual. I’m running a few stats on some projects I have access to, and will upload a few charts as soon as they’re ready. Meanwhile, feel free to send me the output of this:
git-iterate 'echo `flog app` `flog spec`' # if needed, replace "spec" for "test"
…and I’ll chart those for comparison as well. Also, it shouldn’t be difficult to port git-iterate to other source control systems (all of them have a checkout command, right?) and, if you do that, make sure to plug it in the comments.
Have fun! ![]()
Update: fresh off the oven, here’s Rails’ total lines of code. Neat, huh?

Leandro | 22-Jul-08 at 9:25 pm | Permalink
Nice — but what is this ‘flog’ thing I dont have? All I can find are references to inumerous clones of fotolog.net
Carlos Villela | 22-Jul-08 at 9:56 pm | Permalink
Oh, sorry – that’s here
Infovore » links for 2008-07-22 | 22-Jul-08 at 11:30 pm | Permalink
[...] lixo.org :: Git Iterator “I wanted to generate some visualizations of our project’s growth, so I decided to put together a little shell script that looked at the output from git log to spit out some metrics.” Ooh, nice one, Carlos! (tags: git visualisation infographics information sourcecontrol metrics version) [...]
Jonny LeRoy | 23-Jul-08 at 1:47 am | Permalink
Surely this should be called Giterator
Leetel | 24-Jul-08 at 7:09 am | Permalink
I’ve done almost no scripting of git, but isn’t doing `git-reset –hard $COMMIT` on each revision a fairly horrible way of doing this? `git filter-branch` or something should be able to do this without messing around with the working copy, no? [edit] Aaah, it’s even worse than I assumed. The git-iterate script is a sh script, that then does `for i in `ruby -e %x{git log}[...]“..
The Real Adam – git.repo.revs.each(…) | 26-Jul-08 at 4:40 pm | Permalink
[...] Git Iterator – a neat little gizmo for running code against every revision in your Git repository. Yielded this chart showing the growth of the Rails code. [...]
Carlos Villela | 26-Jul-08 at 7:52 pm | Permalink
Leetel, yeah… the code is pretty horrible, there’s no denying that. I am giving git-filter-branch a go, if that improves things, I’ll get it updated on github. Watch that space (and please, feel free to fork, too!)
Update: Thanks, dude! The new code is just a one-liner and a bad regex
The Punch Barrel / Git Iterator | 28-Jul-08 at 4:03 pm | Permalink
[...] lixo.org :: Git Iterator [...]
Recent URLs tagged Visualizations - Urlrecorder | 19-Sep-08 at 7:16 pm | Permalink
[...] Recent public urls tagged “visualizations” → Git Iterator [...]