Skip to content

Instantly share code, notes, and snippets.

@bunnymatic
Created July 9, 2014 15:32
Show Gist options
  • Save bunnymatic/a78deb0e3274af571916 to your computer and use it in GitHub Desktop.
Save bunnymatic/a78deb0e3274af571916 to your computer and use it in GitHub Desktop.
who done it - git blame statistics
Hop into a shell and to the root directory of your project and run
git ls-tree --name-only -z -r HEAD -- $1 | xargs -0 -n1 git blame --line-porcelain | grep "^author "|sort|uniq -c|sort -nr
Then wait a bit. You get a nice sorted list of lines of code and author name.
Add it to your bash profile like this
whodunit() {
git ls-tree --name-only -z -r HEAD -- $1 | xargs -0 -n1 git blame --line-porcelain | grep "^author "|sort|uniq -c|sort -nr
}
and now you have a command-line tool.
Started with http://stackoverflow.com/questions/4589731/git-blame-statistics
@martinn
Copy link

martinn commented May 17, 2024

I wrote a little tool in rust to do this (you get some extra stats like most popular file types too).

https://github.com/martinn/repoblame

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment