Last Updated: February 25, 2016
·
2.186K
· viniciusgama

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

10 Responses
Add your response

There is git-extras which has the git summary command which does the same as the above with percentages.

https://github.com/visionmedia/git-extras

over 1 year ago ·

@twolfson interesting. But I was more interested in the number of lines added and removed. Does git-extras provide me that?
Thanks

over 1 year ago ·

@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?

over 1 year ago ·

@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

over 1 year ago ·

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).

over 1 year ago ·

The best thing that I got was the git-stats script or the gem named git-fame.

over 1 year ago ·

@twolfson might be a good idea. Will see if worth the effort. Thanks :)

over 1 year ago ·

@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

over 1 year ago ·

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

over 1 year ago ·

@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 :)

over 1 year ago ·