Iterate through git commits to gather statistics

0.1.1 2018-01-10 10:48 UTC

This package is auto-updated.

Last update: 2022-01-19 15:17:42 UTC



  • clone this repository
  • install Composer dependencies
  • symlink the gitstats to your /usr/local/bin: ln -s /home/<you>/code/gitstats/gitstats /usr/local/bin/gitstats

Alternatively you can install the Composer package globally (composer global require mnapoli/gitstats)


  • Add a .gitstats.yml file in your current directory:
    'Commit message': "git log -1 --pretty=%B | head -n 1"
    'Commit author': "git log -1 --pretty=%an"
    'Number of files': "find . -type f | wc -l | xargs"
    'Number of directories': "find . -type d | wc -l | xargs"
  • Run the application:
$ gitstats run <git-repository-url>

The repository will be cloned in a temporary directory. All tasks will be run against each commit. Ensure the repository doesn't contain modifications.

The output is formatted as CSV:

Commit,Date,Number of files,Number of directories

You can write the output to a file:

$ gitstats run <git-repository-url> > results.csv

You can then import that into a database or open it up with Excel or whatever.


You can output the result as SQL queries to insert/update a MySQL table:

$ gitstats run <git-repository-url> --format=sql | mysql -u <user> -p <table>

Limit the number of commits processed

You can limit the number of commits to process using the --max parameter:

# Process only 100 commits
$ gitstats run <git-repository-url> --max=100

Show the progress

You can show a progress bar on stderr using the --progress parameter. When using that parameter it makes sense to redirect the output to a file or another command:

$ gitstats run <git-repository-url> --progress > file.csv