Skip to content

mscheltienne/git-credit

Repository files navigation

git-credit

CI codecov License: MIT MSRV pre-commit.ci

Give credit where it's due -- precise per-author contribution stats that see through squash merges.

A contribution analysis tool that accurately attributes lines of code to individual authors, even across squash-merged pull requests, with support for file exclusion filters.

Installation

Homebrew (macOS / Linux)

brew tap mscheltienne/tap
brew install mscheltienne/tap/git-credit

From crates.io

cargo install git-credit

Pre-built binaries

Pre-built binaries for Linux, macOS, and Windows are available on the GitHub Releases page.

From source

git clone https://github.com/mscheltienne/git-credit.git
cd git-credit
cargo install --path .

Usage

# Analyze the current repository
git-credit

# Analyze a specific repository
git-credit --repo /path/to/repo

# Limit to the last 50 commits
git-credit --rev HEAD~50..HEAD

# Only include commits after a date
git-credit --since 2025-01-01

# Exclude files from stats (repeatable)
git-credit --exclude "*.lock" --exclude "*.generated.*"

# Output as JSON instead of a table
git-credit --format json

# Include bot accounts (dependabot, pre-commit-ci, etc. are excluded by default)
git-credit --bots

# Skip GitHub API lookups (faster, but squash merges are attributed to the merge author
# only)
git-credit --no-github

Bot filtering

Bot accounts (identified by [bot]@ in their email address) are excluded from the output by default. Use --bots to include them. When bots are excluded, the summary line shows how many were filtered.

GitHub authentication

To attribute squash-merged PRs to individual authors, git-credit needs a GitHub token. It resolves the token in this order:

  1. --token flag
  2. GITHUB_TOKEN environment variable
  3. GH_TOKEN environment variable
  4. gh auth token (the GitHub CLI)

If no token is found, git-credit runs in --no-github mode automatically with a warning.

Example output

╭──────────────────────────┬───────────────┬─────┬───────┬─────┬───────╮
│ Author                   ┆ Contributions ┆ PRs ┆ +     ┆ -   ┆ Total │
╞══════════════════════════╪═══════════════╪═════╪═══════╪═════╪═══════╡
│ Alice <alice@example.com>┆ 12            ┆ 8   ┆ 1,542 ┆ 389 ┆ 1,931 │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┼╌╌╌╌╌┼╌╌╌╌╌╌╌┤
│ Bob <bob@example.com>    ┆ 8             ┆ 5   ┆ 876   ┆ 201 ┆ 1,077 │
╰──────────────────────────┴───────────────┴─────┴───────┴─────┴───────╯

2 authors (3 bots excluded), 20 commits walked, 13 squash merges expanded

Development

Prerequisites

Setup

git clone https://github.com/mscheltienne/git-credit.git
cd git-credit
pre-commit install
cargo build

Commands

cargo build              # Build
cargo test               # Run all tests
cargo clippy             # Lint
cargo fmt                # Format
cargo deny check         # Audit dependencies
cargo llvm-cov           # Coverage report

License

MIT

About

Give credit where it's due — precise per-author contribution stats that see through squash merges.

Resources

License

Stars

Watchers

Forks

Contributors

Languages