Skip to content

occcat/github-contribution-simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GitHub Contribution Simulator

模拟真实的 GitHub 提交记录,支持自定义时间范围和多种贡献强度模式。

✨ 功能特性

  • 🎯 三种贡献强度:轻量(light)、中等(medium)、重度(heavy)
  • 📅 自定义时间范围:支持从任意年份开始
  • 🎲 真实随机性:工作日更多提交,周末减少,偶尔爆发
  • 合理时间分布:集中在工作时间(9-18点),符合真实习惯
  • 📝 智能提交信息:自动生成符合规范的提交信息
  • 📊 详细统计:生成提交分布图表
  • 🔧 Git 集成:直接生成带时间戳的 Git 提交

🚀 快速开始

1. 仅模拟查看效果

python simulator.py --start 2023-01-01 --intensity medium

2. 生成实际 Git 提交

# 创建新仓库并填充提交
python generate_commits.py --start 2020-01-01 --repo ./my-project

# 使用已有仓库
python generate_commits.py --start 2021-06-01 --repo ./existing-project --intensity heavy

3. 推送到 GitHub

python generate_commits.py \
  --start 2020-01-01 \
  --repo ./project \
  --remote https://github.com/username/repo.git \
  --push

📖 详细用法

simulator.py - 模拟器

仅生成提交计划,不创建实际 Git 提交:

# 基础用法
python simulator.py --start 2023-01-01

# 指定结束日期
python simulator.py --start 2023-01-01 --end 2023-12-31

# 选择强度
python simulator.py --start 2023-01-01 --intensity heavy

# 导出为 JSON
python simulator.py --start 2023-01-01 --export commits.json

# 仅显示统计
python simulator.py --start 2023-01-01 --stats-only

# 固定随机种子(可复现)
python simulator.py --start 2023-01-01 --seed 42

generate_commits.py - 提交生成器

生成实际的 Git 提交:

# 基础用法
python generate_commits.py --start 2023-01-01

# 指定仓库路径
python generate_commits.py --start 2023-01-01 --repo ./my-repo

# 添加远程仓库
python generate_commits.py --start 2023-01-01 --remote https://github.com/user/repo.git

# 生成后自动推送
python generate_commits.py --start 2023-01-01 --push

# 干运行(预览但不执行)
python generate_commits.py --start 2023-01-01 --dry-run

# 强制推送(谨慎使用)
python generate_commits.py --start 2023-01-01 --push --force

🎨 贡献强度模式

模式 每日提交概率 平均提交数 最大提交数 爆发概率
light 40% 1.5 4 5%
medium 70% 3 8 10%
heavy 90% 5 15 15%

周末自动减少: 周末提交概率会乘以 reduction 系数

爆发模式: 偶尔会出现高强度提交日,模拟赶 deadline 的情况

📊 输出示例

🎯 Simulating medium contributor from 2023-01-01 to 2024-02-14...

📊 Statistics:
   Total commits: 847
   Active days: 298
   Avg commits per active day: 2.8
   Max commits in a day: 8

📅 Commits by weekday:
   Mon: 156 █████████████████████████████
   Tue: 168 ████████████████████████████████
   Wed: 145 ███████████████████████████
   Thu: 152 █████████████████████████████
   Fri: 134 █████████████████████████
   Sat:  52 █████████
   Sun:  40 ███████

📝 First 10 commits:
   2023-01-03 10:23 - feat: implement API for clarity
   2023-01-03 14:15 - fix: update validation
   2023-01-04 09:45 - docs: add README per review comments
   ... and 837 more

⚠️ 注意事项

  1. 不可逆操作:生成的 Git 提交会永久改变仓库历史
  2. force push:使用 --force 会覆盖远程历史,谨慎操作
  3. GitHub 限制:GitHub 贡献图只显示最近一年的数据
  4. 时间一致性:提交时间完全基于系统时间,确保正确设置时区

🔒 安全提示

  • 建议在私有仓库测试后再用于公开仓库
  • 不要在已协作的仓库上使用,会改变共享历史
  • 使用 --dry-run 先预览效果

📄 License

MIT License - 自由使用,后果自负 😄

🤝 贡献

欢迎提交 Issue 和 PR!


⚠️ 免责声明:此工具仅供学习和测试使用。请遵守 GitHub 使用条款,不要用于欺骗或误导他人。

About

模拟 GitHub 提交记录的工具 - 支持自定义时间范围和随机性

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors