git根据时间统计代码量
需要在本地项目的根目录下执行命令
1.直接输出在控制台
git log --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --since ==2019-07-01 --until==2019-09-30 --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
2.输出至指定文件
git log --since='2019-07-01' --until='2019-9-30' --format='%aN' | sort -u | while read name; do echo -en "$name,"; git log --since='2019-7-01' --until='2019-9-30' --author="$name" --numstat --pretty=tformat: --no-merges | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf "added lines, %s, removed lines, %s, total lines, %s\n", add, subs, loc }' -; done >> codenums.csv;
参考以下文章:
https://blog.csdn.net/jdz199409/article/details/79425405
https://blog.csdn.net/lihua5419/article/details/84234253
https://blog.csdn.net/jslhl/article/details/81202190
https://segmentfault.com/a/1190000008542123