473

I'm looking for some good tools/scripts that allow me to generate a few statistics from a git repository. I've seen this feature on some code hosting sites, and they contained information like...

  • commits per author
  • commits per day/week/year/etc.
  • lines of code over time
  • graphs
  • ... much more

Basically I just want to get an idea how much my project grows over time, which developer commits most code, and so on.

1
  • 3
    If you cannot install gitstats, you can at least get the number of lines of code by author using basic git commands: git ls-files | while read f; do git blame -w -M -C -C --line-porcelain "$f" | grep -I '^author '; done | sort -f | uniq -ic | sort -n --reverse Commented Dec 3, 2020 at 12:12

10 Answers 10

366

commits per author

git shortlog -s -n 
Sign up to request clarification or add additional context in comments.

6 Comments

exclude merges: git shortlog -sn --no-merges
e flag gives you committers email address git shortlog -sne
Personally I am more interested in how many lines each person was the last one to touch, or total number of lines changed per person. Commits per author is also interesting though.
git shortlog -s -n --since "DEC 31 2017" if you want to filter since a given date. Great for annual reviews ;)
@EnekoAlonso I recommend against using such metrics to measure developer performance. You will likely see false positives masking poor development practices, while some of the best developers will go unnoticed. There is no correlation between number of commits and developer performance, aside from 0 or way, way, way too many.
|
311

Beside GitStats (git history statistics generator) mentioned by xyld, written in Python and requiring Gnuplot for graphs, there is also

10 Comments

see xyld's answer. gitstats (not gitstat) is probably your best bet.
I got gitstats to install after installing readline-6.2.tar.gz and gnuplot. But then found it was missing the libraries necessary to produce the stat images, resulting in missing pngs when viewing gitstats output. So pretty much followed this to get it working correctly: dansanderson.com/blog/2011/03/…
For reference, this set of tools is really nice and simple : github.com/dustin/bindir. They are based on google pithon chart and are simple to use : dustin.github.io/2009/01/11/timecard.html
Cool, this simply works: apt-get install gitstats. Then run it on a git directory like this: gitstats ~/gitdir /tmp/output
|
82

I'm doing a git repository statistics generator in ruby, it's called git_stats.

You can find examples generated for some repositories on project page.

Here is a list of what it can do:

  • General statistics
    • Total files (text and binary)
    • Total lines (added and deleted)
    • Total commits
    • Authors
  • Activity (total and per author)
    • Commits by date
    • Commits by hour of day
    • Commits by day of week
    • Commits by hour of week
    • Commits by month of year
    • Commits by year
    • Commits by year and month
  • Authors
    • Commits by author
    • Lines added by author
    • Lines deleted by author
    • Lines changed by author
  • Files and lines
    • By date
    • By extension

If you have any idea what to add or improve please let me know, I would appreciate any feedback.

3 Comments

Object count and repo size would be nice additions to the General statistics
Commits by: Day of the month. Are they more active at month end?
Awesome thing! Could you also add the statistics about the issues and the pull requests?
48

I tried http://gitstats.sourceforge.net/, starts are very interesting.

Once git clone git://repo.or.cz/gitstats.git is done, go to that folder and say gitstats <git repo location> <report output folder> (create a new folder for report as this generates lots of files)

Here is a quick list of stats from this:

  • activity
    • hour of the day
    • day of week
  • authors
    • List of Authors
    • Author of Month
    • Author of Year
  • files
    • File count by date
    • Extensions
  • lines
    • Lines of Code
  • tags

6 Comments

it needs GnuPlot. To install Gnuplot, on Mac grab the dmg from here miscdebris.net/blog/2009/09/16/install-gnuplot-on-mac-os-x the apply this fix to the gnuplot bin, leancrew.com/all-this/2012/02/fixing-gnuplot-on-os-x-10-7-3
@Loretoparisi, the first link doesnt work anymore, I have created a tutorial on how to use Gitstats on Mac OSX 10.8.2 here: softwarepassion.com/quick-peek-into-your-git-repo-with-gitstats
In ubuntu, sudo apt-get install gnuplot
Hints for getting it running on Windows: stackoverflow.com/a/29384484/24267 Unfortunately, I didn't find gitstats too useful - I'd like to see better breakdown of stats for each author.
|
19

git-bars can show you "commits per day/week/year/etc".

You can install it with pip install git-bars (cf. https://github.com/knadh/git-bars)

The output looks like this:

$ git-bars -p month
370 commits over 19 month(s)
2019-10  7    ▀▀▀▀▀▀
2019-09  36   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2019-08  7    ▀▀▀▀▀▀
2019-07  10   ▀▀▀▀▀▀▀▀
2019-05  4    ▀▀▀
2019-04  2    ▀
2019-03  28   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2019-02  32   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2019-01  16   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2018-12  41   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2018-11  52   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2018-10  57   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2018-09  37   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2018-08  17   ▀▀▀▀▀▀▀▀▀▀▀▀▀▀
2018-07  1    
2018-04  7    ▀▀▀▀▀▀
2018-03  12   ▀▀▀▀▀▀▀▀▀▀
2018-02  2    ▀
2016-01  2    ▀

Comments

14

repostat is an enhanced fork of gitstats tool.

I'm not sure if it's in any way related to the project with the same name on pypi, so your best bet is to download the latest release from GitHub and install it in your Python environment.

As of November 2019, I was able to use v1.2.0 under Windows 7, after making gnuplot available in PATH.


usage: repostat [-h] [-v] [-c CONFIG_FILE] [--no-browser] [--copy-assets]
                git_repo output_path

Git repository desktop analyzer. Analyze and generate git statistics in HTML
format

positional arguments:
git_repo              Path to git repository
output_path           Path to an output directory

optional arguments:
-h, --help            show this help message and exit
-v, --version         show program's version number and exit
-c CONFIG_FILE, --config-file CONFIG_FILE
                        Configuration file path
--no-browser          Do not open report in browser
--copy-assets         Copy assets (images, css, etc.) into report folder
                        (report becomes relocatable)

1 Comment

This worked great for me too in November 2020, version 2.2.0, on Windows 10 with Python 3.8 (3.9 is failing at the moment).
13

Just want to add gitqlite into the mix of answers here, which is a command-line tool that enables execution of SQL queries on git data, such as SELECT * FROM commits WHERE author_name = 'foo' etc.

Full disclosure, I'm a creator/maintainer of the project!

Comments

8

If your project is on GitHub, you now (April 2013) have Pulse (see "Get up to speed with Pulse"):

It is more limited, and won't display all the stats you might need, but is readily available for any GitHub project.

Pulse is a great way to discover recent activity on projects.
Pulse will show you who has been actively committing and what has changed in a project's default branch:

Pulse

You can find the link to the left of the nav bar.

Link

Note that there isn't (yet) an API to extract that information.

Comments

5

And if you prefer hosted solution, you should check out Open Hub (formerly Ohloh.net). It is nice, but don't expect large statistics.

3 Comments

If you are ok with a bit clumsy interface and updates on a ~24h basis, ohlohis good choice, otherwise I'd go for DIY approach.
ohloh is cool, but it only works on public repos. Also, it works with lots of VCSs, not just git.
@naught101 You might try gitential.com as an alternative. It's in beta, but measures and visualizes coding hours, productivity for projects, teams, repos and individual developers.
5

Just yesterday I've added my git-analytics docker-compose file, which builds up several containers to start analyzing multiple git repositories against each other.

It is able to show you commit statistics over time about the author and also several diff statistics.

You can use the provided angular client and also kibana to visualize the statistics.

https://github.com/alexejsailer/git-analytics-docker

It will be improved over time.

Angular Client Screenshot

Angular Client Screenshot

Kibana Client Screenshot

Kibana Client Screenshot]

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.