gitgithubcommitgit-commit

Total number of commits on git/GitHub in a specific timeframe?


How can I know the total number of commits done on a project through the GitHub web interface? How can I get the total number of commits in a specific time frame?

What I can get now is the number of commits done by each developer, not the total one.

Example: https://github.com/BVLC/caffe


Solution

  • First note:
    Since the OP posted his question, the github page has been updated with a graph showing the daily total number of commits, and a way to download this data in CSV format.


    Here are a few other local options to have stats over time, rather than just the count over 1 single time interval:

    Combine git log --pretty=... with sort and count to group commits

    # will print the "committer date" for each commit, formatted Y-M-D:
    git log --pretty="%cs" --since=...
    # count by day:
    git log --pretty="%cs" --since=... | sort -r | uniq -c
    
          6 2024-11-08
         17 2024-11-01
          7 2024-10-30
          1 2024-10-28
        ...
    
    # will print the "committer date" for each commit, formatted Y-M (month only):
    git log --pretty="%cd" --date="format:%Y-%m" --since=...
    # count by month:
    git log --pretty="%cd" --date="format:%Y-%m" --since=... | sort -r | uniq -c
    
         23 2024-11
        240 2024-10
        393 2024-09
        442 2024-08
        ...
    

    you can print the ISO week number and group by that, you will need a bit of extra script-fu to change the output back to readable dates:

    git log --pretty="%cd" --date="format:%G-%V" --since=...
    # count by week:
    git log --pretty="%cd" --date="format:%G-%V" --since=... | sort -r | uniq -c
    
          6 2024-45   # week 45 of year 2024
         25 2024-44   # week 44 of year 2024
         53 2024-43   # ...
         43 2024-42
        ...
    

    I will refer you to man date for the detailed explanations for --date=format:... options.


    Also worth mentioning: there is git shortlog, and this command has a --group=... option

    # a synthetic view by month
    $ git shortlog --group="%cd" --date="%Y-%m" --since="2022-01-01"
    2022-01 (294):
          Merge branch 'jc/unleak-log'
          Merge branch 'ns/tmp-objdir'
          Merge branch 'es/test-chain-lint'
          ...
    2022-02 (284):
          subtree: force merge commit
          branch: move --set-upstream-to behavior to dwim_and_setup_tracking()
          branch: make create_branch() always create a branch
          ...
    2022-03 (392):
          Merge branch 'ps/fetch-atomic' into ps/fetch-mirror-optim
          upload-pack: look up "want" lines via commit-graph
          fetch: avoid lookup of commits when not appending to FETCH_HEAD
          ...