统计所有代码行数
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 }'
标签:loc,git,subs,--,代码,lines,add,统计 From: https://www.cnblogs.com/lanshan-blog/p/16986643.html