git 查看项目成员代码提交行数和次数统计

在实际开发中,常常会想查看自己对于某个项目的贡献,管理者会查看项目下各成员的贡献,就需要使用到 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 }' -

例如查看用户 chenzhanshang@shencom.cn 的代码提交行数统计,查询示例如下图

查看项目每个人提交的代码行数统计

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

查询示例如下图

查询所有用户的提交总次数

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

查询示例如下图

原文地址:https://blog.csdn.net/qq_42301302/article/details/115489995

posted @ 2022-10-30 14:24  寒小韩  阅读(576)  评论(0)    收藏  举报