This directory contains scripts for analyzing Git repository statistics and user contributions.
Choose the script that best fits your needs:
# From repository root
./quick_git_stats.sh <username>
./quick_git_stats.sh <username> --start-date 2024-01-01
./quick_git_stats.sh <username> --start-date 2024-01-01 --end-date 2024-12-31
# From any subdirectory
cd utils && ./quick_git_stats.sh <username># From repository root
./git_analytics.sh <username>
./git_analytics.sh <username> --start-date 2024-01-01
./git_analytics.sh <username> --start-date 2024-01-01 --end-date 2024-12-31
# From any subdirectory
cd utils && ./git_analytics.sh <username># From repository root
python3 git_analytics.py <username> --format json --output report.json
python3 git_analytics.py <username> --start-date 2024-01-01 --format json
python3 git_analytics.py <username> --start-date 2024-01-01 --end-date 2024-12-31 --format json
# From any subdirectory
cd utils && python3 git_analytics.py <username> --format jsonA comprehensive script that analyzes Git repository statistics for a specific user, including:
- Merged Pull Request Count - Number of merged PRs/MRs
- Commit Statistics - Total commits across all branches
- Lines of Code - Lines added, deleted, and net contribution
- Activity Analysis - Commit patterns, time periods, and activity scores
# Basic usage (run from repository root)
./git_analytics.sh <username>
# Example
./git_analytics.sh "username"
# Run from different directory
./git_analytics.sh "username" /path/to/repoThe scripts now automatically detect pull requests by parsing merge commit messages, making them independent of external CLI tools or API access:
- Automatic Detection - Parses "Merge pull request #X" messages from
git log --merges - No External Dependencies - Works without GitHub CLI or API access
- Accurate Counting - Correctly identifies merged pull requests by the specified user
Note: The scripts use the Git commit author name for both commits and pull request detection. Make sure to use the exact author name as it appears in your Git commits.
- Automatic Detection - Parses merge commit messages to identify PR numbers
- Self-contained - No external CLI tools or API access required
- Accurate Counting - Correctly counts pull requests merged by the specified user
- Cross-platform - Works on any Git repository with merge commits
- Total Commits - All commits by user across all branches
- Unique Commits - Deduplicated commit count
- Branch Analysis - Commits per branch breakdown
- Recent Activity - Commits in last 30 days
- Time Analysis - Commits by year and day of week
- Files Modified - Total number of files touched
- Current LOC - Lines of code in files currently in repository
- Lines Added - Total lines added by user (including merge commits)
- Lines Deleted - Total lines deleted by user (including merge commits)
- Net Contribution - Net lines added (additions - deletions)
- Merge Commit Support - Accurately counts lines from merged pull requests
- Activity Timeline - First and last commit dates
- Days Active - Total days between first and last commit
- Yearly Breakdown - Commits per year
- Activity Patterns - Most active day of week
- Activity Score - Calculated engagement metric
git- Git version control systemawk- Text processing utilitywc- Word count utilitysort- Sorting utilityuniq- Unique line filtering
The scripts are now self-contained and don't require GitHub CLI, GitLab CLI, or API access for pull request detection.
================================
Git Analytics Summary
================================
User: username
Repository: example-repo
Generated: 2024-12-19 14:30:25
Quick Stats:
Total Commits: 45
Unique Commits: 42
Recent Activity (30 days): 12
Activity Score: 1050
Counting Pull Requests...
Pull Requests (from merge commits): 4
PR Details:
PR #42: a1b2c3d Merge pull request #42 from feature/user-authentication
PR #38: e4f5g6h Merge pull request #38 from feature/api-endpoints
PR #25: i7j8k9l Merge pull request #25 from feature/database-migration
PR #12: m0n1o2p Merge pull request #12 from feature/unit-tests
Counting Commits...
Total Commits: 45
Unique Commits: 42
Commits by Branch:
main: 25 commits
feature/auto-save: 15 commits
bugfix/auth: 5 commits
Recent Activity (Last 30 days):
Commits in last 30 days: 12
Counting Lines of Code...
Files Modified: 23
Total Lines of Code: 15420
Lines Added: 2847
Lines Deleted: 1234
Net Lines: 1613
Detailed Commit Statistics...
First Commit: 2024-01-15
Last Commit: 2024-12-19
Days Active: 338
Commits by Year:
2024: 45 commits
Most Active Day of Week:
Wednesday: 12 commits
================================
Analysis Complete
================================
All statistics have been generated for user: username
- Team Performance - Track individual contributions
- Project Health - Monitor activity levels
- Resource Planning - Identify most active contributors
- Personal Analytics - Track your own contributions
- Portfolio Building - Generate statistics for resumes
- Code Review - Understand your impact on projects
- Contributor Recognition - Acknowledge top contributors
- Community Health - Monitor project activity
- Documentation - Generate contribution reports
# The script automatically shows recent activity, but you can modify it
# Edit the script to change the "30 days ago" period# Run for multiple users
for user in user1 user2 user3; do
./git_analytics.sh "$user" > "report_${user}.txt"
done# Save output to file
./git_analytics.sh username > analytics_report.txt
# Save with timestamp
./git_analytics.sh username > "analytics_$(date +%Y%m%d_%H%M%S).txt"- Merged PR Counting - Requires GitHub/GitLab CLI or API access
- Private Repos - API calls may fail for private repositories
- Large Repositories - May be slow for very large codebases
- Git History - Only analyzes current Git history (not deleted branches)
"Not a Git repository"
# Make sure you're in a Git repository
cd /path/to/your/repo
./utils/git_analytics.sh username"No commits found for user"
# Check if the username matches Git author names
git log --pretty=format:"%an" | sort -u | grep -i "username""Could not determine PR count"
# This usually means no merge commits were found for the user
# Check if the user has merged any pull requests
git log --merges --author="username" --oneline- Large Repositories: The script may take time for large codebases
- Network Issues: API calls may timeout on slow connections
- Memory Usage: Very large repositories may use significant memory
The activity score is calculated as:
Activity Score = (Total Commits Γ 10) + (Recent Commits Γ 50)
This gives more weight to recent activity while considering overall contribution.
The script is designed to be:
- Self-contained - Minimal external dependencies
- Cross-platform - Works on macOS, Linux, and Windows (with Git Bash)
- Extensible - Easy to add new metrics or modify existing ones
Advanced Git analytics with JSON output support and enhanced data processing.
- JSON Output - Machine-readable format for further processing
- Enhanced Statistics - More detailed analysis than bash version
- File Extension Analysis - Breakdown by file types
- Largest Files - Top 10 largest files modified
- Export Support - Save reports to files
# Basic usage
python3 git_analytics.py "username"
# With date range
python3 git_analytics.py "username" --start-date 2024-01-01 --end-date 2024-12-31
# JSON output
python3 git_analytics.py "username" --format json
# Save to file
python3 git_analytics.py "username" --format json --output report.json
# Analyze different repository
python3 git_analytics.py "username" --repo /path/to/repo- Standard library modules:
os,sys,json,subprocess,datetime,collections,argparse - No external dependencies required
Lightweight script for fast statistics overview.
- Fast Execution - Minimal processing time
- Essential Stats - Core metrics only
- Simple Output - Clean, readable format
- No Dependencies - Uses only standard Unix tools
# From repository root
./utils/quick_git_stats.sh <username>
./utils/quick_git_stats.sh <username> --start-date 2024-01-01
./utils/quick_git_stats.sh <username> --start-date 2024-01-01 --end-date 2024-12-31
# From any subdirectory (scripts auto-detect Git root)
cd utils && ./quick_git_stats.sh <username>
cd example-repo && ../quick_git_stats.sh <username>Quick Git Stats for: username
==================================
Total Commits: 45
Recent Commits (30 days): 12
Files Modified: 23
Lines Added: 2847
Lines Deleted: 1234
Net Lines: 1613
==================================
All scripts support date range filtering to analyze contributions within specific time periods:
- Format:
YYYY-MM-DD(e.g.,2024-01-01) - Start Date:
--start-date- Filter commits from this date (inclusive) - End Date:
--end-date- Filter commits until this date (inclusive)
# Analyze commits from January 1, 2024 onwards
./quick_git_stats.sh "username" --start-date 2024-01-01
# Analyze commits in 2024 only
./quick_git_stats.sh "username" --start-date 2024-01-01 --end-date 2024-12-31
# Analyze commits until December 31, 2023
./git_analytics.sh "username" --end-date 2023-12-31
# Python with date range and JSON output
python3 git_analytics.py "username" --start-date 2024-01-01 --end-date 2024-12-31 --format json- Time-based Analysis: Focus on specific periods (quarters, years, sprints)
- Performance: Faster processing for large repositories
- Trend Analysis: Compare activity across different time periods
- Project Phases: Analyze contributions during specific project phases
- Flexible Execution: Scripts automatically detect and navigate to Git repository root
| Feature | Quick Stats | Full Analytics | Python Analytics |
|---|---|---|---|
| Speed | β‘ Fast | π Medium | π Medium |
| Output Format | Text | Text | Text/JSON |
| Merged PR Counting | β No | β Yes | β Yes |
| File Analysis | β No | β Yes | β Yes |
| Dependencies | Minimal | Medium | Python + libs |
| Export Support | β No | β No | β Yes |
| Customization | β No | β Yes | β Yes |
- Daily Check-ins - Quick overview of your contributions
- Team Standups - Fast team member statistics
- CI/CD Integration - Automated reporting in pipelines
- Detailed Reports - Comprehensive analysis
- Project Reviews - Full contribution assessment
- Documentation - Complete user activity reports
- Data Processing - Further analysis with other tools
- API Integration - Programmatic access to statistics
- Custom Reports - Tailored analytics for specific needs