开发者

How can I sum up the lines added/removed by a user in a git repo?

开发者 https://www.devze.com 2022-12-29 10:44 出处:网络
I am trying to find the total number of lines added and total number of lines removed by a user in a git repository. I looked at How to count total lines changed by a specific author in a Git reposito

I am trying to find the total number of lines added and total number of lines removed by a user in a git repository. I looked at How to count total lines changed by a specific author in a Git repository?, which had the command git log --author="<authorname>" --pretty=tformat: --numstat, but the answer fai开发者_开发知识库led to give a script(however simple) to total the lines changed. What's the simplest way to sum up the lines added/removed?


$ git log --author="<authorname>" --pretty=tformat: --numstat | perl -ane'
> $i += $F[0]; $d += $F[1]; END{ print "added: $i removed: $d\n"}'


Also doable with awk:

git log --author="<authorname>" --pretty=tformat: --numstat | awk -F" " '{ added += $1; removed += $2 } END { print "added: ",  added, "removed:", removed }'
0

精彩评论

暂无评论...
验证码 换一张
取 消