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 failed 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 }'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With