gitgithub

Count Git commits per period


is there a way to count the number of commits in certain period (e.g. the last year from 2015-03-01 to 2016-03-01) for git (GitHub) repositories?


Solution

  • To count the commits in a date range in your current branch do this:

    git rev-list --count HEAD --since="Dec 3 2015" --before="Jan 3 2016"
    

    If you want the count for all branches in one go use --all additionally:

    git rev-list --count --since="Dec 3 2015" --before="Jan 3 2016" --all
    

    If you want to exclude merge commits, use the option --no-merges:

    git rev-list --count --since="Dec 3 2015" --before="Jan 3 2016" --all --no-merges