21

Does anyone know of a command or script that will output each author that has committed to the project followed by the number of lines they have contributed.

e.g. something similar to the following:

Author       Insertions   Deletions
Bob Dole     1240         409
Sarah J      481          140
Jim Helper   388          23

Cheers, Ben

Quinn Taylor
  • 44,553
  • 16
  • 113
  • 131
  • This can probably be accomplished with a simple awk/sed script over the output of `git-blame`. http://www.kernel.org/pub/software/scm/git/docs/git-blame.html – Mark Rushakoff Apr 28 '10 at 16:26

3 Answers3

9

This gives the line statistics for a particular author:

git log --author="_Your_Name_Here_" --pretty=tformat: --numstat \
| gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
aspiring_sarge
  • 2,355
  • 1
  • 25
  • 32
Jonathan Schneider
  • 26,852
  • 13
  • 75
  • 99
  • Can you extend your answer to output stats for all authors? – mrgloom Oct 13 '17 at 10:59
  • 2
    @mrgloom, this should work: `while read i; do git log --author="$i" --pretty=tformat: --numstat | { printf "$i: "; gawk ' { add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -; }; done < <(git shortlog -sne | sed 's/[^<]*<\([^>]*\)>/\1/' | sort -u)` – Fabio A. Oct 24 '17 at 23:19
4

A quick search dug up GitStats, though that only generates HTML output.

Update: A bit more digging turned up LookAtGit, which seems more along the lines of what you were looking for.

Second Update: As mentioned on a comment to the original question, this can also be accomplished with git in conjunction with sed/awk. There's a nice example of how to do this right here on SO.

Community
  • 1
  • 1
Damien Wilson
  • 4,540
  • 3
  • 21
  • 27
1

git shortlog -sne

zs2020
  • 53,766
  • 29
  • 154
  • 219