i want to see the number of removed/added line, grouped by author for a given branch in git history. there is git shortlog -s
which shows me the number of commits per author. is there anything similar to get an overall diffstat?
If you go to the graphs/contributors page, you can see a list of all the contributors to the repo and how many lines they've added and removed.
The git blame command is used to examine the contents of a file line by line and see when each line was last modified and who the author of the modifications was.
git shortlog | grep -E '^[ ]+\w+' | wc -l if you want to get total number and git shortlog | grep -E '^[^ ]' if you want to get commits number for every contributor. Thanks for pointing out wc -l .
It's an old post but if someone is still looking for it:
install git extras
brew install git-extras
then
git summary --line
https://github.com/tj/git-extras
one line code(support time range selection):
git log --since=4.weeks --numstat --pretty="%ae %H" | sed 's/@.*//g' | awk '{ if (NF == 1){ name = $1}; if(NF == 3) {plus[name] += $1; minus[name] += $2}} END { for (name in plus) {print name": +"plus[name]" -"minus[name]}}' | sort -k2 -gr
explain:
git log --since=4.weeks --numstat --pretty="%ae %H" \ | sed 's/@.*//g' \ | awk '{ if (NF == 1){ name = $1}; if(NF == 3) {plus[name] += $1; minus[name] += $2}} END { for (name in plus) {print name": +"plus[name]" -"minus[name]}}' \ | sort -k2 -gr # query log by time range # get author email prefix # count plus / minus lines # sort result
output:
user-a: +5455 -3471 user-b: +5118 -1934
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