A powerful Git repository analysis tool that provides detailed metrics, growth statistics, future projections, and contributor insights for your Git repositories.
git-metrics
is a command-line utility that analyzes Git repositories to provide comprehensive insights about repository history, structure, and growth patterns. The tool examines your repository's Git object database to reveal historical trends, identify storage-heavy components, and visualize contributor activity over time. With this data, it generates projections for future repository growth and helps identify optimization opportunities.
Key features include:
- Repository metadata analysis (first commit, age)
- Year-by-year growth statistics for Git objects (commits, trees, blobs) and their on-disk size
- Future growth projections based on historical trends
- Directory structure analysis with size impact indicators
- Identification of largest files in the repository
- File extension distribution analysis
- Contributor statistics showing top committers and authors over time
- Git
The easiest way to install git-metrics
is to download a prebuilt binary from the GitHub releases page.
-
Download the latest release for Linux (64-bit):
curl -L https://github.com/steffen/git-metrics/releases/latest/download/git-metrics-linux-amd64.tar.gz -o git-metrics.tar.gz
-
Unpack the archive:
tar -xzf git-metrics.tar.gz
-
Optional: Move it to a directory in your PATH:
sudo mv git-metrics /usr/local/bin/
-
Download the latest release for macOS (Intel or Apple Silicon):
curl -L https://github.com/steffen/git-metrics/releases/latest/download/git-metrics-darwin-arm64.zip -o git-metrics.zip
-
Unzip the archive:
unzip git-metrics.zip
-
Optional: Move it to a directory in your PATH:
sudo mv git-metrics /usr/local/bin/
-
When downloaded via browser you may need to remove the quarantine attribute in order to run the tool:
xattr -d com.apple.quarantine git-metrics
-
Analyze the current directory as a Git repository:
git-metrics
-
Analyze a specific repository:
git-metrics -r /path/to/repository
Option | Description |
---|---|
-r , --repository |
Path to Git repository (default: current directory) |
--debug |
Enable debug output |
--no-progress |
Disable progress indicators |
--version |
Display version information and exit |
git-metrics
provides several sections of output:
- Run information: Details about when, where, and with which versions the tool was executed.
- Repository information: Basic metadata about your repository including path, remote URL, age, and commit history.
- Historic & estimated growth: Year-by-year breakdown of Git object growth (commits, trees, blobs) and disk usage, with future projections based on historical trends.
- Largest directories: Hierarchical view of directory sizes and their impact on repository size, showing both absolute and percentage values.
- Largest files: Identification of the largest files in your repository by compressed size, along with their last commit year.
- File extensions: Analysis of file extensions and their contribution to repository size.
- Contributors: Statistics on authors and committers over time, showing who has contributed the most commits by year.
- Commits, Trees, Blobs: These columns show the cumulative count of Git objects. Commits represent saved changes, trees represent folder snapshots, and blobs represent file versions.
- On-disk size: Shows the compressed size of Git objects as stored in Git's database (
.git/objects
). Objects are often stored using delta compression (storing only changes between similar objects). - Percentages (%): In the growth table, percentages show estimated yearly growth relative to current totals. In directory and file listings, percentages show the proportion of total repository objects or size.
- Growth projections: Future estimates (marked with
*
) are calculated based on growth patterns from the last five years. - Directory markers: Files or directories marked with
*
are not present in the latest commit (they were moved, renamed, or removed).
- Track repository growth over time
- Identify large files that may impact clone and fetch times
- Project future storage requirements for Git repositories
- Optimize repository size by identifying problematic files
Contributions are welcome! Please feel free to submit a Pull Request.
If you prefer to build git-metrics
from source, follow these steps:
- Git
- Go 1.23.2 or newer
-
Clone the repository:
git clone https://github.com/steffen/git-metrics.git cd git-metrics
-
Build the binary:
go build
After building, you can run the tool as described in the "Running the Tool" section.