gitgithub

Show a contributor's number of commits and lines of code contributed


I would like to view a summary of my total number of commits and total number of lines of code which I have committed to a particular repository on GitHub. Is there any way to do this using either: GitHub, Git Shell on Windows, or another tool which easily works on Windows or in a web browser?

Here is my current strategy:

Commits

  1. Go to the URL https://github.com/repositoryname/projectname/commits?author=myname with Google Chrome
  2. Hit Ctrl+F and type in the word "committed", to see the number of times this word appears on the page
  3. Scroll down to the bottom of the page and click the Older button. Repeat from step 2 and keep increasing the total count until done.

Lines of Code

  1. Open Git Hub and go to the repo directory
  2. git log --author="myemail" --oneline --shortstat > gitstat.log
  3. Maybe I will write a little program to tally up the number of insertions, or count it by hand

Surely there must be a more convenient way of doing this? Note: I am looking for an answer that does not require bash, and is easily accessible to Windows users.


Solution

  • On GitHub’s repo summary bar, click the contributor count:

    screenshot of repo summary bar with “contributors” highlighted

    The contributor list includes number of commits, lines added, and lines deleted for each person.

    screenshot of contributor list

    Alternatively, to count commits with just the Git CLI, you can use git shortlog --summary:

    ~/src/linguist $ git shortlog --summary --numbered --no-merges
       607  Joshua Peek
       568  Arfon Smith
       321  Paul Chaignon
       245  Ted Nyman
       132  Brandon Keepers
       131  Adam Roben
        81  Alhadis
        80  Lars Brinkhoff
         ⋮
    

    This doesn’t have GitHub’s advantage of grouping multiple name/e-mail combos belonging to the same user, mind.