Commit Tracker
A Python script to fetch and export GitHub commits for a specific user across an organization.
Features
- Fetch all commits for a user in a GitHub organization
- Support for date range filtering
- Multiple output formats: CSV (default), JSON, simple text, and detailed text
- Automatic pagination handling (up to GitHub's 1000 result limit)
- Rate limit monitoring
- Progress tracking with verbose mode
Requirements
- Python 3.6+
requestslibrary
Installation
- Clone this repository:
git clone git@github.com:david4096/commit-tracker.git
cd commit-tracker- Install dependencies:
pip install requestsUsage
Basic Usage
./fetch_commits.py <org-name> <username> --token <your-github-token>Examples
Export to CSV (default):
./fetch_commits.py {ORGANIZATION} {USER} \
--token YOUR_GITHUB_TOKEN \
--start-date 2023-01-01 \
--end-date 2025-12-09 > commits.csvWith date range and verbose output:
./fetch_commits.py {ORGANIZATION} {USER} \
--token YOUR_GITHUB_TOKEN \
--start-date 2024-01-01 \
--end-date 2024-12-31 \
--verbose > commits.csvJSON output:
./fetch_commits.py {ORGANIZATION} {USER} \
--token YOUR_GITHUB_TOKEN \
--format json > commits.jsonSimple text format:
./fetch_commits.py {ORGANIZATION} {USER} \
--token YOUR_GITHUB_TOKEN \
--format simpleDetailed text format:
./fetch_commits.py {ORGANIZATION} {USER} \
--token YOUR_GITHUB_TOKEN \
--format detailedCommand Line Arguments
org- GitHub organization name (required)username- GitHub username to search for (required)--token- GitHub personal access token (required)--start-date- Start date in YYYY-MM-DD format (optional)--end-date- End date in YYYY-MM-DD format (optional)--format- Output format:csv,json,simple, ordetailed(default: csv)--verbose,-v- Enable verbose output with progress information
GitHub Token Setup
- Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
- Click "Generate new token (classic)"
- Give it a descriptive name (e.g., "Commit Tracker")
- Select scopes:
- For public repositories:
public_repo - For private repositories:
repo(full control)
- For public repositories:
- Generate and copy the token
- Use it with the
--tokenparameter
Important: Never commit your token to version control. Always pass it as a command-line argument or use environment variables.
Output Formats
CSV (Spreadsheet)
Comma-separated values with columns:
- Date
- SHA (short)
- Repository
- Author
- Message (first line)
- URL
Perfect for opening in Excel, Google Sheets, or other spreadsheet applications.
JSON
Full GitHub API response data for each commit. Useful for further processing or analysis.
Simple Text
One line per commit with date, SHA, repository, and message.
Detailed Text
Multi-line format with commit details and clickable URLs.
Limitations
- GitHub's search API has a maximum limit of 1000 results per query
- If you hit this limit, the script will warn you to narrow your date range
- Rate limits apply based on your GitHub token's permissions
License
MIT License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.