Git repository commit statistics collector and visualizer
Project description
๐ oh-my-gitstats
ไธญๆ | English
A Python CLI tool for collecting git commit statistics and visualizing them as interactive HTML charts.
โจ Features
- ๐ Batch Collection โ Scan multiple git repositories recursively
- โก Incremental Sync โ Only fetch new commits since last collection
- ๐ One-Step Workflow โ
gitstats autodoes everything in one command - ๐ Line Charts โ Track changes over time with metric & granularity switching
- ๐๏ธ Calendar Heatmaps โ Visualize commit activity with year-based filtering
- ๐ฏ Aggregated & Individual Views โ See combined or per-repo statistics
- ๐ VS Code Integration โ Open repo folders directly from the HTML report
๐ Installation
pip install oh-my-gitstats
Or install from source:
git clone https://github.com/amomorning/oh-my-gitstats.git
cd oh-my-gitstats
pip install -e .
โก Quick Start
First time, collect from each project directory (paths are auto-recorded in config):
cd ~/projects && gitstats collect .
cd ~/work && gitstats collect .
After that, one command does collect โ sync โ visualize โ open browser:
gitstats auto
You can also manually edit the config file to add directories:
# The config file is auto-created at:
~/.gitstats/settings.json
{
"collect_paths": [
"/home/user/projects",
"/home/user/work"
]
}
Options:
| Option | Description |
|---|---|
-q, --quiet |
Suppress output messages |
--check |
Check GitHub archive status (requires network; set GITHUB_TOKEN for private repos) |
--no-open |
Do not open the HTML file in browser after generation |
๐ Commands
collect โ Collect Commit Data
Scan a directory for git repositories and export to JSON:
gitstats collect /path/to/repos
| Option | Description |
|---|---|
-o, --output |
Directory to save JSON files (default: ~/.gitstats/data) |
-q, --quiet |
Suppress output messages |
--skip |
Skip repos that already have a JSON file |
--check |
Check GitHub archive status |
sync โ Incremental Sync
Update existing JSON files with only new commits โ much faster than re-collecting:
gitstats sync
| Option | Description |
|---|---|
-q, --quiet |
Suppress output messages |
--check |
Check GitHub archive status |
Typical workflow with multiple directories:
# One-time: collect from different locations
gitstats collect /path/to/work-projects
gitstats collect /path/to/personal-projects --skip
# Later: update all at once
gitstats sync
visualize โ Generate Visualization
Create an interactive HTML file from collected data:
gitstats visualize
| Option | Description |
|---|---|
-o, --output |
HTML file path (default: ~/.gitstats/stats.html) |
Granularity and metric can be switched dynamically in the generated HTML โ no need to regenerate.
โ๏ธ Configuration
Config file at ~/.gitstats/settings.json (auto-created on first run):
{
"data_dir": "~/.gitstats/data",
"output_html": "~/.gitstats/stats.html",
"collect_paths": []
}
| Field | Description |
|---|---|
data_dir |
Where JSON files are stored |
output_html |
Where HTML visualization is generated |
collect_paths |
Directories for gitstats auto to scan (auto-populated when you run collect) |
๐ GitHub Token (Optional)
--check queries the GitHub API to check archive status. Without authentication, only public repositories can be checked (rate limit: 60 requests/hour).
If
GITHUB_TOKENis not set, a warning will be printed when using--check.
To check private repositories, set the GITHUB_TOKEN environment variable:
Linux / macOS
export GITHUB_TOKEN=ghp_your_token_here
gitstats sync --check
Windows (PowerShell)
Set for current session:
$env:GITHUB_TOKEN="ghp_your_token_here"
gitstats sync --check
Set permanently: Settings โ System โ About โ Advanced system settings โ Environment Variables โ User variables โ New
How to get a token
- Go to GitHub โ Settings โ Developer settings โ Personal access tokens โ Tokens (classic)
- Click Generate new token (classic)
- Give it a name (e.g.
oh-my-gitstats) - Under Select scopes, no additional scopes are needed for public repos
- To access private repositories, check the
reposcope - Click Generate token and copy the value (starts with
ghp_)
Note: Use Tokens (classic), not Fine-grained tokens. With a token, the rate limit increases to 5,000 requests/hour.
๐ Output
The generated HTML contains:
-
๐ Line Chart โ Changes over time with metric selector (Lines Changed / Commit Count) and granularity selector (Day/Week/Month). Click legend to toggle projects.
-
๐๏ธ Aggregate Heatmap โ Combined activity across all repos with year selector (All Years / specific year).
-
๐ Individual Heatmaps โ Per-repository calendar views in a responsive grid, each with sync status indicator and a "Continue" / "Archived" button to open in VS Code.
๐ JSON Format
Each repository generates a JSON file (~/.gitstats/data/{repo_name}.json):
{
"repo_name": "my-project",
"repo_path": "/absolute/path/to/my-project",
"last_commit_hash": "a1b2c3d4...",
"sync_status": "synced",
"is_archived": false,
"commits": [
{
"timestamp": "2024-01-15T10:30:00",
"additions": 45,
"deletions": 12
}
]
}
last_commit_hash โ HEAD hash at collection time. During sync, repos with a matching hash are skipped instantly.
sync_status โ Sync state with remote:
| Status | Description |
|---|---|
โ
synced |
In sync with remote |
โ๏ธ local_changes |
Local has uncommitted changes, remote is up-to-date |
โฌ๏ธ remote_ahead |
Local is clean, but remote has new commits |
โ ๏ธ diverged |
Local has uncommitted changes and remote has new commits |
๐ local_only_clean |
No remote configured, local is clean |
๐ง local_only_dirty |
No remote configured, local has uncommitted changes |
โ ๏ธ network_error_clean |
Remote exists but fetch failed, local is clean |
โ ๏ธ network_error_dirty |
Remote exists but fetch failed, local has uncommitted changes |
is_archived โ Whether the repo is archived on GitHub (set by --check). Values: true, false, or null (not checked). Archived repos show a grayed-out "Archived" button.
๐ง Requirements
- Python 3.9+
- click, gitpython, pyecharts, jinja2, requests
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oh_my_gitstats-0.3.1.tar.gz.
File metadata
- Download URL: oh_my_gitstats-0.3.1.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62924eaec9c02020eff798cb3c87335d5674a419470a76e85479cce1d1be75ff
|
|
| MD5 |
df8bdbe29b9965fc809a9444202e6699
|
|
| BLAKE2b-256 |
a01943e899b09ccdd0f8ebd5f21ef048ba72c3ab10f3ca03f3b233429ed66cc0
|
File details
Details for the file oh_my_gitstats-0.3.1-py3-none-any.whl.
File metadata
- Download URL: oh_my_gitstats-0.3.1-py3-none-any.whl
- Upload date:
- Size: 22.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9674b72a854b3f2c058c5357a423e6828f2c97494e8ea3461e33215ae6baa575
|
|
| MD5 |
9d90ebc623e9725acc80a5020d772d64
|
|
| BLAKE2b-256 |
634c4a8b3a7f23a5b99b301db3bb3dea38d72a3093c82eb598cc9d9e03920eb0
|