Skip to content

Instantly share code, notes, and snippets.

@hoefling
Created January 18, 2017 00:26
Show Gist options
  • Save hoefling/0e63c7e0c598f3c9efdeba7a1c292663 to your computer and use it in GitHub Desktop.
Save hoefling/0e63c7e0c598f3c9efdeba7a1c292663 to your computer and use it in GitHub Desktop.
stats in git repo
# count commits, sort by author
$ git shortlog -s -n
# same as above, w/o merge commits
$ git shortlog -s -n --no-merges
# same as above on all remote branches
$ git shortlog -s -n --no-merges --all
# counts insertions/deletions/delta locs for all authors in repo
# inspired by http://stackoverflow.com/questions/1265040/how-to-count-total-lines-changed-by-a-specific-author-in-a-git-repository
_rule="========================================================"; printf "\n %-18s %12s %12s %10s\n" "Name" "Insertions" "Deletions" "Delta"; printf "%56.56s\n" "$_rule"; git log --format='%aN' | sort -u | while read name; do git log --author="$name" --pretty=tformat: --numstat --no-merges | grep -v '.xsl\|\.xml' | awk -v author="$name" '{ ins += $1; dels += $2; delta += $1 - $2 } END { printf "%-18s %13s %12s %10s\n", author, ins, dels, delta }' -; done; printf "%56.56s\n" "$_rule"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment