Skip to content

Instantly share code, notes, and snippets.

Last active Jul 18, 2022
What would you like to do?
visualize git logs accross multiple repositories

Are you working too much?

Here's a simple way to find out!

Just cd into your projects folder (that is, a folder that contains many git repositories) and run this little bash script:

echo "project,timestamp" > $TMPLOG;
for i in *; do; 
   if [ -d $i ] && [ -d $i/.git ]; then;
      cd $i;
      git log --since='last 2 months' --author="$(git config --get" --pretty=format:"$i,%ai" >> $TMPLOG;
      echo "" >> $TMPLOG;
      cd ..;
grep . $TMPLOG > project-logs.csv;

Then run this little R script.

needs(readr, dplyr, chron, RColorBrewer)

d <- read_csv('~/nytg/2016/project-logs.csv') %>%
    filter(project != "") %>%
    mutate(ts=as.POSIXct(timestamp)) %>%
    mutate(pid=as.factor(project)) %>%
    mutate(date=as.Date(ts), time=as.POSIXct(format(ts, '%H:%M:%S'), format='%H:%M:%S'))

plot(d$date, d$time, type='n', ylim=rev(range(d$time)))
ticks_time <- seq(as.numeric(as.POSIXct('00:00', format='%H:%M')), as.numeric(as.POSIXct('23:59', format='%H:%M')), 7200)
tick_lbls <- format(as.POSIXct(ticks_time, origin = '1970-01-01'), '%H:%M')
axis(2, at = ticks_time, labels = tick_lbls, las = 2) 

dates <- as.Date(levels(as.factor(d$date)))
weekends <- dates[is.weekend(dates)]
abline(v=dates, col='#f2f2f2', lwd=2)
abline(v=weekends, col='#e9d9d9', lwd=2)

colors <- brewer.pal(8, 'Dark2')
points(d$date, d$time, pch=19, col=colors[as.numeric(d$pid) %% length(colors)], cex=1)

If you don't have needs, install it via


The resulting plot shows you all your commits over the last 2 months:


Tested on OSX. Feel free to fork and link your version in the comments below.

Copy link

daattali commented Aug 16, 2016

I think the second line of the R script should change from d <- read_csv('log.csv') %>% to d <- read_csv('project-logs.csv') %>%

Copy link

daattali commented Aug 16, 2016

This work is great. I extended it a bit and had some more fun with it

Thanks for this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment