Skip to content

Instantly share code, notes, and snippets.

@non
Last active April 4, 2018 13:09
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save non/254e41747d7ac4eae0e1 to your computer and use it in GitHub Desktop.
Save non/254e41747d7ac4eae0e1 to your computer and use it in GitHub Desktop.
Roughly-estimate total contributions to a Git repository (adds + deletes). Arguably overstates the impact of a move (you get twice the file size in those cases).
#!/bin/sh
git log --numstat | awk '/^Author: /{author=$0} /^[0-9]+\t[0-9]+/{n = $1 + $2; d[author] += n; t += n} END { for(a in d) { printf("%6d %6.3f%% %s\n", d[a], d[a] * 100 / t, a)}}' | sort -rn
# written less illegibly, it is:
#
# git log --numstat | \
# awk '
# /^Author: /{author=$0}
# /^[0-9]+\t[0-9]+/{n = $1 + $2; d[author] += n; t += n}
# END { for(a in d) { printf("%6d %6.3f%% %s\n", d[a], d[a] * 100 / t, a)}}
# ' | sort -rn
@luc-j-bourhis
Copy link

Cool! If you rename that script git-contrib, you can then execute it by typing git contrib, which is kinda cooler…

@asj
Copy link

asj commented Mar 17, 2016

Looks like you need to ignore case for the author. Authors with inconsistent case sign-off are shown more than once in the output.

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