git 代码统计

bg

统计所有代码行数

git log --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 log --pretty=tformat: --numstat

读取每一行日志并分成数个字段进行处理,并在处理完成后执行END指定的命令输出汇总信息

awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }'

统计一定时间内产生的代码行数

git log --since=2019-01-01 --until==2019-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 log --since =2019-01-01 --until==2019-12-31 --author="psr" --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 }'

posted @ 2022-12-16 10:25  忘崽牛仔  阅读(124)  评论(0编辑  收藏  举报