Showing an intermixed short log of a bunch of git repositories

Ángel Ortega

I store all my git repositories under the same directory, unsurprisingly called ~/git. I needed a way to have a quick list of what I have done in all of them in a given time, so I wrote a script named (probably incorrectly) my-git-metachangelog.sh. This script iterates all subdirectories, finds all that are git repositories, takes a shortlog for all of them, and sorts by date. The fields shown are: date, time, project and the first line of the commit message.

By default, shows the short log for the last 6 months. It accepts an optional unique argument with the number of months to summarize.

This is an example of its output:

2008-12-11 18:25:29 gruta: Changed all POD docum. in templates to head2.
2008-12-11 17:04:37 gruta: New templates 'main_top' and 'main_bottom'.
2008-12-11 10:57:19 grutatxt: The option 'no-pure-verbatim' has been docum.
2008-12-11 10:25:26 grutatxt: Don't move to 'blockquote' if in 'pre' mode.
2008-12-11 10:19:44 grutatxt: Strip bold form head2 documentation.
2008-12-11 10:17:11 grutatxt: 'pod2grutatxt' creates 'NAME' (Closes: #1016).
2008-12-11 10:08:07 grutatxt: Improved header generation in pod2grutatxt.
2008-12-11 09:49:30 grutatxt: New '--no-pure-verbatim' mode (Closes: #1015).
2008-12-10 14:24:06 mp-5.x: Updated TODO.
2008-12-10 07:25:44 gruta: New field 'description' (Closes:  #1050).
2008-12-09 20:20:52 mp-5.x: Small documentation tweaks.
2008-12-09 13:47:48 gruta: More comments in templates.
2008-12-07 19:58:33 mp-5.x: New syntax color for special doc. blocks.
2008-12-07 08:42:38 mp-5.x: Version 5.1.1 RELEASED.
...

And the script:

#!/bin/sh
# my-git-metachangelog.sh
# Angel Ortega <angel@triptico.com> - public domain

MONTHS=$1

[ -z "$MONTHS" ] && MONTHS=6

for r in *
    do ([ -d $r ] && cd $r &&
        git rev-parse HEAD > /dev/null 2>&1 &&
        git log --no-merges \
        --since="$MONTHS months ago" \
        --pretty="format:%ai $r: %s%n")
    done | \
grep -v '^$' | sed -e 's/+[0-9][0-9][0-9][0-9] //' | \
sort -r | less

2010-12-08 update: Fixed to also work on bare repositories.