LinuxCommandLibrary

gitstats

Generate statistics from a Git repository

TLDR

Generate statistics for a local repository

$ gitstats [path/to/git_repo/.git] [path/to/output_folder]
copy

View generated statistics in a web browser on Windows (PowerShell)/macOS/Linux
$ [Invoke-Item|open|xdg-open] [path/to/output_folder/index.html]
copy

Display help
$ gitstats [[-h|--help]]
copy

SYNOPSIS

gitstats [-h|-v] [-r] [-c COMMIT] [-s SIZE] [-H HEIGHT] [-W WIDTH] [-T TITLE] [-N] [-M] <git-directory> [output-directory]

PARAMETERS

-h, --help
    Display usage help and exit.

-v, --version
    Display gitstats version information.

-r
    Use relative timestamps in report graphs.

-c, --commit=COMMIT
    Starting commit hash/tag (default: HEAD).

-s, --size=SIZE
    Max graph size in pixels (default: 1000).

-H, --height=HEIGHT
    Author commits graph height (default: 10).

-W, --width=WIDTH
    Author commits graph width (default: 180).

-T, --title=TITLE
    Custom HTML report title (default: "Repository Statistics").

-N
    Skip copying git-logo.png to output.

-M
    Omit meta-robots=noindex,nofollow tag.

DESCRIPTION

gitstats is a Perl-based tool for generating detailed, self-contained HTML statistics reports from Git repositories. It processes commit history, authorship, file changes, and code metrics to create interactive visualizations including SVG graphs and tables.

Key report sections include:
Activity graphs: Commits by hour, day, week, month.
Author stats: Top contributors by commits, lines added/removed, first/last activity.
File & line changes: Modifications by file type, blame data, churn rates.
Trends: Hour-of-day and weekday patterns.

The output is a single directory with index.html that requires no server or plugins to view. It uses Git commands like log and blame for data extraction, making it non-intrusive.

Perfect for code reviews, project summaries, or open-source contribution analysis. Runs quickly on small repos but scales to larger ones with adjustable parameters. No installation needed beyond Perl and Git.

CAVEATS

Requires Perl 5.8+ and Git 1.5+. Slow on huge repos (>100k commits). Static SVG output lacks modern JS interactivity. No support for Git submodules.

INSTALLATION

git clone https://github.com/hannesedor/gitstats.git
cd gitstats
chmod +x gitstats
./gitstats /path/to/repo

OUTPUT STRUCTURE

index.html: Main report.
gitstats-*.svg: Graphs.
gitstats.js, gitstats.css: Styling/scripts.

HISTORY

Created by Hannes Eder in 2009 as a simple Git stats tool. Open-sourced on GitHub (hannesedor/gitstats). Community contributions added features like relative dates; last significant updates ~2013. Remains popular for lightweight reporting.

SEE ALSO

git(1), git-log(1), git-blame(1)

Copied to clipboard