/

Git log 统计分析

统计个人增删行数

USERNAME 替换为想查询的 user.name

git config user.name

git log --author="USERNAME" --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 }' -
added lines: 82813, removed lines: 53707, total lines: 29106

统计每个人增删行数

git log --shortstat | grep -E "(Author: )(\s*(\w+)){2}|fil(e|es) changed" | awk '
{
if($1 ~ /Author/) {
author = $2" "$3
} else {
files[author]+=$1
inserted[author]+=$4
deleted[author]+=$6
}
}
END { for (key in files) { print "Author: " key "\n\tfiles changed: ", files[key], "\n\tlines inserted: ", inserted[key], "\n\tlines deleted: ", deleted[key] } }
'

统计每个人提交次数

git shortlog -sn --no-merges

cloc

AlDanial/cloc | github 代码统计。

cloc source/

186 text files.
186 unique files.
3 files ignored.

github.com/AlDanial/cloc v 1.84 T=0.16 s (1112.3 files/s, 138678.8 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
Markdown 183 6028 0 16788
-------------------------------------------------------------------------------
SUM: 183 6028 0 16788
-------------------------------------------------------------------------------

忽略某些路径的更改

git log -- . ":(exclude)sub"
git log -- . ":!sub"

References

– EOF –