Git Stats
Analyze any local git repository for contributor rankings, LOC by language, commit activity patterns, and monthly trends.
Quick Start
CODEBLOCK0
Output Sections
- - Top Contributors — ranked by commit count with email
- Lines of Code — total files/lines, broken down by extension
- File Types — file count by extension
- Activity by Day — which days of the week get the most commits
- Activity by Hour — peak coding hours
- Monthly Trend — commit volume over the last 12 months (configurable with
--months)
Options
| Flag | Description |
|---|
| INLINECODE1 | Analyze a specific branch |
| INLINECODE2 |
Only include commits after this date |
|
--until | Only include commits before this date |
|
--months N | Monthly trend window (default: 12) |
|
--json | Output as JSON for programmatic use |
|
--no-loc | Skip line counting (much faster on large repos) |
Dependencies
- -
git CLI (must be on PATH) - Python 3.8+ (stdlib only, no pip packages needed)
Git Stats
分析任意本地Git仓库,获取贡献者排名、按语言统计的代码行数、提交活动模式以及月度趋势。
快速开始
bash
分析当前仓库
python3 scripts/git_stats.py
分析指定仓库
python3 scripts/git_stats.py /path/to/repo
输出JSON格式供进一步处理
python3 scripts/git_stats.py --json
按日期范围筛选
python3 scripts/git_stats.py --since 2025-01-01 --until 2025-12-31
指定分支
python3 scripts/git_stats.py --branch main
跳过代码行数统计以加快速度
python3 scripts/git_stats.py --no-loc
输出部分
- - 顶级贡献者 — 按提交次数排序,附带邮箱信息
- 代码行数 — 文件/行数总计,按扩展名细分
- 文件类型 — 按扩展名统计的文件数量
- 按日活动 — 一周中提交最活跃的日期
- 按小时活动 — 编码高峰时段
- 月度趋势 — 过去12个月的提交量(可通过--months配置)
选项
| 标志 | 描述 |
|---|
| --branch | 分析指定分支 |
| --since |
仅包含此日期之后的提交 |
| --until | 仅包含此日期之前的提交 |
| --months N | 月度趋势窗口(默认:12) |
| --json | 输出JSON格式,便于程序化使用 |
| --no-loc | 跳过行数统计(大型仓库时速度更快) |
依赖项
- - git 命令行工具(必须位于PATH环境变量中)
- Python 3.8+(仅使用标准库,无需pip包)