Stats for your git repo
IFS=''
for author in $(git log --all --format="%an" | sort -u)
do
git log --author="$author" --pretty=tformat: --numstat | \
grep -v node_modules | \
awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END \
{ printf "%s +++ / %s --- / %s ++- \n",add,subs,loc }' -
done
Written by Vinícius Gama
Related protips
10 Responses
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/46110/15927fc52919e9223adc7ed99e125d4d.jpeg)
There is git-extras
which has the git summary
command which does the same as the above with percentages.
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/24826/02970a5c2b23a211a5e2b3a566d19615.jpeg)
@twolfson interesting. But I was more interested in the number of lines added and removed. Does git-extras provide me that?
Thanks
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/46110/15927fc52919e9223adc7ed99e125d4d.jpeg)
@viniciusgama I do not think it does. I am semi-clear and semi-unclear of the purpose of your protip. Can you provide more of an explanation?
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/24826/02970a5c2b23a211a5e2b3a566d19615.jpeg)
@twolfson I was just trying to get the top contributors on a git repo. Similar to what github does in his graph page.
example: https://github.com/viniciusgama/strider/contributors
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/46110/15927fc52919e9223adc7ed99e125d4d.jpeg)
Ah, okay. I don't think they have a method for that. You might want to consider create a pull request for that. It would be nice to see that as a flag on git summary
(e.g. git summary --lines
).
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/24934/736212_10200976756252420_836055407_o.jpg)
The best thing that I got was the git-stats script or the gem named git-fame.
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/24826/02970a5c2b23a211a5e2b3a566d19615.jpeg)
@twolfson might be a good idea. Will see if worth the effort. Thanks :)
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/24826/02970a5c2b23a211a5e2b3a566d19615.jpeg)
@emgiezet seems like git-stats have what I want but it was kind of hard to use and I gave up. The git-fame seems pretty nice and maybe I'll try to write a port for it as a npm package. Will be a good opportunity to study :)
Thanks
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/8720/7f9d997af5eafade31ebd807bce68f24.jpeg)
I had to write something equivalent for a project which didn't use git author because we were pairing- we just used a special format of commit messages. https://github.com/compwron/pairSee
![](https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/24826/02970a5c2b23a211a5e2b3a566d19615.jpeg)
@lindaTW, that would be my next step. In my current project we work in pairs too and we use a special format for the commit messages.
Thanks for sharing :)