views:

967

answers:

4

Previously I have enjoyed TortoiseSvn's ability to generate simple commit stats for a given SVN repository. I wonder what is available in Git and am particularly interested in :

  • Number of commits per user
  • Number of lines changed per user
  • activity over time (for instance aggregated weekly changes)

Any ideas?

+3  A: 

First, you don't have to pull anything (as in network pull), because you have the whole repository and the whole history locally. I'm pretty sure there are tools that will give you statistics, but sometimes you can just be creative with the command lines. For instance, this (just out of my head) will give you the number of commits per user:

git log --pretty=format:%ae \
| gawk -- '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'

Other statistics you asked for may need more thought put into it. You may want to see the tools available. Googling for git statistics points to the GitStats tool, which I have no experience with and even less idea of what it takes to get it run on windows, but you can try.

Michael Krelin - hacker
+1  A: 

Thanks to hacker for answering this question. However, I found these modified versions to be better for my particular usage:

git log --pretty=format:%an \
| awk '{ ++c[$0]; } END { for(cc in c) printf "%5d %s\n",c[cc],cc; }'\
| sort -r

(using awk as I don't have gawk on my mac, and sorting with most active comitter on top.) It outputs a list like so:

 1205 therikss
 1026 lsteinth
  771 kmoes
  720 minielse
  507 pagerbak
  269 anjohans
  205 mfoldbje
  188 nstrandb
  133 pmoller
   58 jronn
   10 madjense
    3 nlindhol
    2 shartvig
    2 THERIKSS
Jesper Rønn-Jensen
I had no idea you have Mac - mention of tortoise made me think of windows. But anyway, I'm glad you've found your way. My snippet was just an example and a starting point.
Michael Krelin - hacker
+10  A: 

Actually, git already has a command for this:

git shortlog

in your case, it sounds like you're interested in this form:

git shortlog -sne

See the --help for various options.

You may also be interested in the GitStats project. They have a few examples, including the stats for the Git project. From the GitStat main page:

Here is a list of some statistics generated currently:

  • General statistics: total files, lines, commits, authors.
  • Activity: commits by hour of day, day of week, hour of week, month of year, year and month, and year.
  • Authors: list of authors (name, commits (%), first commit date, last commit date, age), author of month, author of year.
  • Files: file count by date, extensions
  • Lines: Lines of Code by date
Pat Notz
This is exactly what I was looking for. Amazing that you can actually replace the code lines in my example with "git shortlog -sn"Vote up for this answer
Jesper Rønn-Jensen
A: 

See this gitstat project

http://mirror.celinuxforum.org/gitstat/

Lee jung.seung
Thanks, @hacker already mentioned this url in his answer
Jesper Rønn-Jensen