Turn any local Git repository's history into a readable report: who did the work, which files churn the most, when the team actually commits, how concentrated the knowledge is, and who keeps the longest streak.
$ gitstats ~/projects/my-app
Git history report
========================================
Commits: 342 (18 merges)
Authors: 7
Files touched: 96
Lines: +18420 / -7311
Timespan: 2025-03-04 to 2026-11-20 (626 days)
Bus factor: 2 (Ana, Ben)
Longest streak: 14 days (2026-04-06 to 2026-04-19)
Top authors (top 10)
----------------------------------------
Ana 148 commits (43.3%) +8211/-2904 74 files
...
Requires Python 3.10+ and Git. No third-party dependencies.
pip install .
gitstats --helpOr run it without installing:
PYTHONPATH=src python -m gitstats.cli ~/projects/my-appgitstats [PATH] [options]| Option | What it does |
|---|---|
PATH |
Repository to analyse (default: current directory) |
--since DATE |
Only commits after DATE (e.g. 2026-01-01, 3 months ago) |
--until DATE |
Only commits before DATE |
--author NAME |
Only commits by NAME (substring match, like git log) |
--top N |
How many authors/files to list (default: 10) |
--json |
Emit the full report as JSON instead of text |
--from-file FILE |
Analyse a saved git log --numstat dump instead of running Git |
Examples:
# This quarter's work only
gitstats . --since 2026-10-01 --json > q4-report.json
# One contributor's footprint
gitstats . --author "Ana" --top 5
# Analyse a log captured on another machine
git log --format='%x1e%H%x1f%an%x1f%ae%x1f%aI%x1f%s%x1f%P' --numstat > history.log
gitstats --from-file history.log- Overview — commits, merges, authors, files touched, lines added/removed, and the timespan the history covers.
- Top authors — commits, share of history, lines changed, files touched.
- Most-changed files — the churn hotspots; files that appear in many commits are usually the ones worth refactoring or documenting first.
- Commit rhythms — commits by weekday, by hour, and by month, so you can see when the team actually works.
- Bus factor — the smallest number of top authors whose commits cover at least 50% of the history. A bus factor of 1 means one person leaving takes half the project's knowledge with them.
- Streaks — the longest run of consecutive days with at least one commit, overall and per author.
- Shell out to Git, don't parse
.gitby hand. Git's on-disk format is an implementation detail;git logis the stable interface, and it keeps the tool correct for worktrees, shallow clones, and future formats. - A machine-readable log format. The parser asks Git for records
separated by
\x1eand fields by\x1f— control characters that cannot appear in a commit subject — so parsing never has to guess where a field ends, the way regexes over the default pretty format do. - Parsing, statistics, and rendering are separate modules. The parser
produces plain dataclasses,
statscomputes pure numbers from them, andreportonly formats. That split is what lets the test suite cover the statistics without ever creating a repository. - Renames are attributed to the new path.
--numstatreports a rename asold => new; counting it under the new name keeps churn attached to the file that exists now.
src/gitstats/
models.py # Commit / FileChange dataclasses
parser.py # git log --numstat -> Commit objects
collector.py # runs `git log`, handles empty/non-repo cases
stats.py # author/file/rhythm/bus-factor/streak aggregation
report.py # text and JSON rendering
cli.py # argparse entry point
tests/
test_parser.py test_stats.py test_report.py test_cli.py
python -m pytest30 tests, including end-to-end runs against real repositories created in temporary directories.
MIT — see LICENSE.