Git统计个人提交代码行数

1. Git统计个人提交代码行数

 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

结果图:

在这里插入图片描述

这个统计是以当前所在分支为基准统计的,所以如果是迭代式的往后更迭,统计最新一个分支就可以了。

2. Git统计项目总行数

 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 }' -

效果图:

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_40985985/article/details/109177114
今日推荐