360 Secure SkillHub
360 安全技能中心

Git Stats

通过 Python 脚本调用 git 分析本地仓库,输出贡献者排名、按语言统计的代码行数与文件类型分布、按星期和小时的提交频率及近 12 个月趋势,支持分支与日期范围过滤,并可输出 JSON 便于后续处理。

johnnywang2001
johnnywang2001
热度 56.36
最近更新 2026-05-11 17:35:58
分类:数据依赖:代码执行 / 读写文件应用场景:报告撰写 / 数据处理

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add git-stats
Metadata
name
git-stats
description
Analyze git repository statistics including contributor rankings, lines of code by language, commit frequency by day/hour, monthly activity trends, and file type breakdowns. Use when asked to analyze a repo, show git stats, get contributor info, count lines of code, or visualize commit activity patterns.

Git Stats

Analyze any local git repository for contributor rankings, LOC by language, commit activity patterns, and monthly trends.

Quick Start

# Analyze current repo
python3 scripts/git_stats.py

# Analyze a specific repo
python3 scripts/git_stats.py /path/to/repo

# JSON output for further processing
python3 scripts/git_stats.py --json

# Filter by date range
python3 scripts/git_stats.py --since 2025-01-01 --until 2025-12-31

# Specific branch
python3 scripts/git_stats.py --branch main

# Skip LOC counting for faster results
python3 scripts/git_stats.py --no-loc

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
--branch Analyze a specific branch
--since 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)