Skip to content

swedishembedded/git-stats

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-stats

Comprehensive git contributor statistics — installable as git stats.

Analyze commits across one or many repositories and produce side-by-side developer comparisons with cost-efficiency metrics. Output as an interactive TUI, plain Markdown, or a self-contained Markdown + PNG diagram report.


Features

  • Interactive TUI — scrollable contributor summary and a weekly breakdown as one row per week per author (week, name, email, commits, line deltas, net, files), per-repo tabs, keyboard navigation (↑/↓, Tab, ←/→, PgUp/PgDn).
  • Markdown output — pipe-delimited tables ready for GitHub, Confluence, or any Markdown renderer.
  • Diagram report — SVG/PNG charts (commits/week, lines/week, cumulative commits, cost efficiency) written alongside a report.md file.
  • Parallel analysis — repositories are walked concurrently via Rayon; large mono-repos finish in seconds.
  • Submodule support — when run inside a repo each submodule is reported separately.
  • Multi-repo scan — when run outside any repo the tool recursively discovers every git repository under the given path.
  • Flexible filtering--me, --user, --from/--to, --branch.
  • Cost & efficiency metrics — supply a YAML file with hourly rates and the report adds estimated hours, estimated cost, cost-per-commit, cost-per-line, commits/day, and lines/day for every developer, enabling direct financial comparison.

Installation

From source

git clone https://github.com/swedishembedded/git-stats.git
cd git-stats
make install          # installs to ~/.local/bin  (no sudo required)

Ensure ~/.local/bin is on your PATH, then:

git stats --help

System-wide (requires sudo)

make install/system   # installs to /usr/local/bin

Debian / Ubuntu package

make install/deb      # builds git-stats_<version>_amd64.deb and dpkg -i it

Usage

Usage: git-stats [OPTIONS] [PATH]

Arguments:
  [PATH]  Root path to analyze [default: .]

Options:
      --me                    Only commits by the current git user
      --user <NAME_OR_EMAIL>  Filter to a contributor (name or email substring)
      --from <YYYY-MM-DD>     Start date
      --to   <YYYY-MM-DD>     End date (default: today)
      --branch <BRANCH>       Branch to analyze (default: current HEAD)
      --markdown              Print Markdown report to stdout
      --diagrams              Write Markdown + SVG/PNG charts to --output-dir
      --output-dir <DIR>      Output directory for diagrams (default: ./git-stats-report/)
      --config <CONFIG.YAML>  Developer hourly-rate config
  -h, --help
  -V, --version

Interactive TUI (default)

# Analyze the repo in the current directory
git stats

# Analyze a specific repo, last 90 days
git stats --from 2026-01-01 /path/to/repo

# Only your own commits
git stats --me

Keybindings:

Key Action
q / Esc Quit
Tab Toggle Summary ↔ Weekly view
/ Switch repository tab
/ / j / k Scroll rows
PgUp / PgDn Page scroll
Home / End Jump to first / last row

Markdown report

git stats --markdown --from 2025-01-01 > report.md

Diagram report

git stats --diagrams --from 2025-01-01 --output-dir ./reports/q1
# Writes reports/q1/report.md  +  *.svg  +  *.png

Filter to one developer

git stats --user alice --from 2026-01-01 --markdown

Multi-repo scan (run outside any repo)

git stats --markdown /path/to/workspace
# Discovers and reports on every git repo found under that path

Cost & Efficiency Analysis

Create a YAML file describing your team's hourly rates:

# rates.yaml
working_hours_per_day: 8
working_days_per_week: 5
currency: "USD"
developers:
  - email: "alice@company.com"
    name: "Alice"
    hourly_rate: 85.00
  - email: "bob@company.com"
    name: "Bob"
    hourly_rate: 65.00

Pass it with --config:

git stats --config rates.yaml --markdown --from 2025-01-01

The report gains these additional columns:

Column Description
Rate Configured hourly rate
Est. Hours active_days × working_hours_per_day
Est. Cost est_hours × hourly_rate
Cost/Commit Estimated cost per commit
Cost/Line Estimated cost per changed line
Commits/Day Average commits on days with activity
Lines/Day Average lines changed on active days

Note: Hours are estimated from active days (days with at least one commit), not calendar days. This is intentionally conservative and suitable for comparative analysis, not billing.

An example-rates.yaml is included in the repository as a starting point.


Make targets

make build             # release binary  (alias: build/release)
make build/debug       # debug binary
make build/deb         # .deb package

make install           # install to ~/.local/bin  (alias: install/user)
make install/system    # install to /usr/local/bin  (sudo)
make install/deb       # build + dpkg -i

make uninstall         # remove from ~/.local/bin
make uninstall/system  # remove from /usr/local/bin  (sudo)
make uninstall/deb     # dpkg -r git-stats

make check             # fmt + clippy + test
make check/fmt
make check/clippy
make check/test

make clean             # cargo clean  (alias: clean/build)
make clean/deb
make clean/all

make help              # this list

Override the install prefix:

make install PREFIX=/opt/local

Project structure

src/
  main.rs          — entry point, orchestration
  cli.rs           — CLI arguments (clap derive)
  config.rs        — YAML developer-rate config
  discovery.rs     — repo discovery (in-repo + submodules, recursive scan)
  analysis.rs      — parallel commit walking (rayon + git2)
  model.rs         — data types (WeeklyBucket, AuthorStats, RepoReport, …)
  error.rs         — error types (thiserror)
  output/
    tui.rs         — ratatui TUI renderer
    markdown.rs    — Markdown report
    diagrams.rs    — plotters SVG charts → resvg PNG

Key dependencies: git2 (libgit2 bindings, vendored), rayon (parallelism), ratatui + crossterm (TUI), plotters + resvg (charts), clap, chrono, serde/serde_yaml.


License

Released under the MIT License.

About

A comprehensive git stats utility that gives you comprehensive productivity stats for a bunch of repositories

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors