Git统计提交代码数据
使用git log可以统计git数据,详细git log命令参考git log。要统计项目的代码量可以使用代码统计插件:Statistic。
1、代码提交次数
git log --author="username" --oneline | wc -l
2、代码的行数
可以设定范围或者条件统计某个用户的提交代码量。
2.1、用户名
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换成自己的用户名
2.2、时间范围
git log --since=2018-01-01 --until=2018-12-31 --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 }'
把时间切换成自己想要统计的时间段就可以了
2.3、用户名&时间段
统计某人在某段时间内的代码更改数量:
git log --author="username" --since=2018-10-01 --until=2018-12-31 --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 }' -
注:想要统计自己在git上的代码的更改数量,首先平常的项目是通过git来管理的,并且在输入以上命令统计的时候,需要先通过git进入到项目中。
参考资料:
git上统计自己开发代码的行数
统计gitlab中每人的代码提交量
Git 代码统计
精彩的人生需要浪漫、无畏和勇气。