Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show number of changed lines per author in git

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?

like image 1000
knittl Avatar asked May 07 '10 08:05

knittl


People also ask

How do I count the number of lines in a GitHub repository?

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.

Which command shows the author of each line in git?

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.

What is the command to check the count of logs in git?

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 .


2 Answers

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

like image 132
Sebastien Horin Avatar answered Sep 30 '22 10:09

Sebastien Horin


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 
like image 24
alswl Avatar answered Sep 30 '22 10:09

alswl