Git Stats

Submitted by Calvin on Fri, 02/19/2016 - 11:36

Some command line fu to check some basic git repo stats.  Links to more info.

COUNT LINES OF CODE IN REPO BY USER:
git ls-tree -r -z --name-only HEAD -- | xargs -0 -n1 git blame --line-porcelain HEAD |grep  "^author "|sort|uniq -c|sort -nr

http://stackoverflow.com/questions/4589731/git-blame-statistics

 

COUNT LINES CHANGED BY USER
git log --author="_Your_Name_Here_" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -

http://stackoverflow.com/questions/1265040/how-to-count-total-lines-cha…

 

COUNT TOTAL LINES IN REPO
git ls-files | xargs wc -l

http://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-g…