githubSearchCommits
Search GitHub commits by message, author, hash, or date to retrieve SHAs or fetch content changes (diffs/patches). Use query-based, filter-only, or combined searches for precise results. Works for public and private repositories, with optional commit content fetching.
Instructions
Search GitHub commits by message, author, hash, or date. Returns SHAs for github_fetch_content (branch=SHA). Can fetch commit content changes (diffs/patches) when getChangesContent=true.
SEARCH OPTIONS:
- Query-based search:
- exactQuery: Exact phrase matching (e.g., "bug fix")
- queryTerms: Multiple keywords with AND logic (e.g., ["readme", "typo"])
- orTerms: Keywords with OR logic (e.g., ["bug", "fix"] finds commits with either)
- Combine: queryTerms=["api"] + orTerms=["auth", "login"] = api AND (auth OR login)
- Filter-only search (no query required):
- Search by author, committer, hash, date, etc.
- Example: Just committer="monalisa" to find all commits by that user
- Example: Search by commit hash (including head_sha/base_sha from a PR): hash="<sha>"
- Combined search:
- Mix queries with filters for precise results
- Example: queryTerms=["fix"] + author="jane" + author-date=">2023-01-01"
EXAMPLES: • Search commits with "readme" AND "typo": queryTerms=["readme", "typo"] • Search exact phrase "bug fix": exactQuery="bug fix" • Search by committer only: committer="monalisa" • Search by author name: author-name="Jane Doe" • Search by commit hash (including head_sha/base_sha from a PR): hash="8dd03144ffdc6c0d486d6b705f9c7fba871ee7c3" • Search before date: author-date="<2022-02-01"
CONTENT FETCHING:
- Set getChangesContent=true to fetch actual commit changes: • Gets file diffs and patches for up to 10 commits • Shows changed files, additions, deletions • Includes code patches (first 1000 chars) • Works for both public AND private repositories • Most effective when owner and repo are specified
TOKEN OPTIMIZATION NOTICE:
- getChangesContent=true is EXTREMELY expensive in tokens
- Each commit's diff/patch content consumes significant tokens
- Limited to 1000 characters per patch and 5 files per commit for efficiency
- Use sparingly and only when code changes are essential to your task
- use fetch_github_file_content to get the full content of the file
Input Schema
Name | Required | Description | Default |
---|---|---|---|
author | No | GitHub username of commit author (e.g., "octocat") | |
author-date | No | Filter by author date (e.g., "<2022-02-01", ">2020-01-01", "2020-01-01..2021-01-01") | |
author-email | No | Email of commit author | |
author-name | No | Full name of commit author | |
committer | No | GitHub username of committer (e.g., "monalisa") | |
committer-date | No | Filter by commit date (e.g., "<2022-02-01", ">2020-01-01", "2020-01-01..2021-01-01") | |
committer-email | No | Email of committer | |
committer-name | No | Full name of committer | |
exactQuery | No | Exact phrase to search for in commit messages (e.g., "bug fix") | |
getChangesContent | No | Set to true to fetch actual commit changes (diffs/patches). Works for both public and private repositories, most effective with owner and repo specified. Limited to first 10 commits for rate limiting. WARNING: EXTREMELY expensive in tokens - each commit diff can consume thousands of tokens. | |
hash | No | Commit SHA (full or partial, including head_sha/base_sha from a PR as returned by github_search_pull_requests) | |
limit | No | Maximum number of results to fetch | |
merge | No | Only merge commits (true) or exclude them (false) | |
orTerms | No | Array of search terms with OR logic (e.g., ["bug", "fix"] finds commits with either word) | |
order | No | Sort order | desc |
owner | No | Repository owner (use with repo param) | |
parent | No | Parent commit SHA | |
queryTerms | No | Array of search terms with AND logic (e.g., ["readme", "typo"] finds commits with both words) | |
repo | No | Repository name (use with owner param) | |
sort | No | Sort by date field | |
tree | No | Tree SHA | |
visibility | No | Repository visibility filter |