IT序号网

git代码统计知识解答

luoye 2021年05月25日 程序员 157 0

命令行

查看git上的个人代码量:

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 }' -

结果示例:(记得修改 username)

added lines: 120745, removed lines: 71738, total lines: 49007

统计每个人增删行数

git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --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 }' -; done

结果示例

Max-laptop    added lines: 1192, removed lines: 748, total lines: 444 
chengshuai    added lines: 120745, removed lines: 71738, total lines: 49007 
cisen    added lines: 3248, removed lines: 1719, total lines: 1529 
max-h    added lines: 1002, removed lines: 473, total lines: 529 
max-l    added lines: 2440, removed lines: 617, total lines: 1823 
mw    added lines: 148721, removed lines: 6709, total lines: 142012 
spider    added lines: 2799, removed lines: 1053, total lines: 1746 
thy    added lines: 34616, removed lines: 13368, total lines: 21248 
wmao    added lines: 12, removed lines: 8, total lines: 4 
xrl    added lines: 10292, removed lines: 6024, total lines: 4268 
yunfei.huang    added lines: 427, removed lines: 10, total lines: 417 
³Ÿö    added lines: 5, removed lines: 3, total lines: 2

查看仓库提交者排名前 5

git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r | head -n 5

贡献值统计

git log --pretty='%aN' | sort -u | wc -l

提交数统计

git log --oneline | wc -l

添加或修改的代码行数:

git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'


发布评论
IT序号网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!

git图形化统计工具 - windows下gitstats的安装和使用知识解答
你是第一个吃螃蟹的人
发表评论

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。