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 }'
精彩评论