Skip to content
gh-search-commits logo

GitHub CLI: Search Commits

gh-search-commits

Use when searching commit history across GitHub repositories - provides syntax for filtering by author, committer, dates, hashes, and merge commits with proper exclusion handling

SKILL.md

Full skill instructions

GitHub CLI: Search Commits

Overview

Search for commits across GitHub repositories using gh search commits. Filter by author, committer, dates, commit hashes, and more.

When to Use This Skill

Use this skill when searching commits across GitHub:

  • Finding commits by author or committer across repos/​orgs
  • Searching commit messages for keywords across repositories
  • Filtering by commit dates or hashes in specific repos
  • Looking for merge commits across an organization
  • Searching in specific repositories or organizations
  • Need to exclude certain results (requires -- flag)

Syntax

gh search commits [<query>] [flags]

Key Flags Reference

Author & Committer Filters

FlagPurposeExample
--author <string>Filter by author username--author octocat
--author-name <string>Filter by author name--author-name "John Doe"
--author-email <string>Filter by author email--author-email [email protected]
--author-date <date>Filter by authored date--author-date ">2024-01-01"
--committer <string>Filter by committer username--committer octocat
--committer-name <string>Filter by committer name--committer-name "Jane Doe"
--committer-email <string>Filter by committer email--committer-email [email protected]
--committer-date <date>Filter by committed date--committer-date "<2024-06-01"

Commit Attributes

FlagPurposeExample
--hash <string>Filter by commit hash--hash 8dd03144
--parent <string>Filter by parent hash--parent abc123
--tree <string>Filter by tree hash--tree def456
--mergeFilter merge commits only--merge

Repository Filters

FlagPurposeExample
--owner <strings>Filter by repo owner--owner github
-R, --repo <strings>Search in specific repo--repo cli/​cli
--visibility <strings>Filter by visibility--visibility public

Output & Sorting

FlagPurposeExample
-L, --limit <int>Max results (default: 30)--limit 100
--sort <string>Sort by author-date or committer-date--sort author-date
--order <string>Sort direction: asc or desc--order asc
--json <fields>JSON output--json sha,author,commit
-w, --webOpen in browser-w

JSON Output Fields

Available fields: author, commit, committer, id, parents, repository, sha, url

Exclusion Syntax (Critical!)

When using inline query exclusions (negations with -), you MUST use the -- separator:

✅ Correct: gh search commits -- "search-terms -qualifier:value" ❌ Wrong: gh search commits "search-terms" --flag=-value ❌ Wrong: gh search commits "search-terms" --flag=!value ❌ Wrong: gh search commits --author-not=username

Examples:

  • gh search commits -- "fix -author:dependabot" (exclude author)
  • gh search commits -- "merge -committer:bot" (exclude committer)
  • gh search commits -- "deploy -merge:true" (exclude merge commits)
  • gh search commits -- "refactor -author-date:<2024-01-01" (exclude date range)

Why the -- separator is required: The -- tells the shell to stop parsing flags and treat everything after it as arguments. Without it, -qualifier:value inside quotes may be misinterpreted.

Critical Syntax Rules

When to Use Flag Syntax vs Query Syntax

Decision Tree:

Does your search include:
  - Any exclusions (NOT, minus, without, except)?  → Use Query Syntax with `--`
  - Complex boolean logic (OR, AND)?              → Use Query Syntax with `--`

Otherwise:
  - Simple positive filters only?                  → Use Flag Syntax

Flag Syntax (for positive filters):

gh search commits "bug fix" --author octocat --repo cli/​cli

Query Syntax with -- (required for exclusions):

gh search commits -- "deploy -author:dependabot -author:renovate"

⚠️ NEVER mix both syntaxes in a single command!

1. Exclusions and Negations

CRITICAL: When excluding results, you MUST use query syntax with the -- separator.

Exclusion Syntax Rules:
  1. Use the -- separator before your query
  2. Use -qualifier:value format (dash prefix for negation)
  3. Quote the entire query string
Examples:

Single exclusion:

# Exclude specific author
gh search commits -- "deploy -author:dependabot"

# Exclude specific committer
gh search commits -- "merge -committer:bot"

# Exclude merge commits
gh search commits -- "fix -merge:true"

Multiple exclusions:

# Exclude multiple authors
gh search commits -- "deployment -author:dependabot -author:renovate"

# Exclude author and date range
gh search commits -- "refactor -author:bot -author-date:<2024-01-01"

# Exclude merge commits and specific authors
gh search commits -- "feature -merge:true -author:bot"

Combine with positive filters using flags:

# Wrong - mixing syntaxes:
gh search commits "fix" --author octocat -committer:bot  # ❌

# Correct - use query syntax for everything when excluding:
gh search commits -- "fix author:octocat -committer:bot"  # ✅

PowerShell exclusions:

# Use --% to prevent PowerShell parsing
gh --% search commits -- "fix -author:dependabot"
Common Exclusion Patterns:
User RequestCommand
"Find commits but not by bots"gh search commits -- "deploy -author:dependabot -author:renovate"
"Commits excluding merge commits"gh search commits -- "feature -merge:true"
"Commits not by specific author"gh search commits -- "refactor -author:olduser"
"Commits excluding specific date range"gh search commits -- "bug -author-date:<2024-01-01"
"Commits not by multiple committers"gh search commits -- "fix -committer:bot -committer:ci"
"Commits excluding specific email"gh search commits -- "update -author-email:[email protected]"
"Commits not in specific repo"gh search commits -- "security -repo:old/​deprecated"

2. Date Formats

Use ISO8601 format (YYYY-MM-DD) with comparison operators:

gh search commits --author-date ">2024-01-01"
gh search commits --committer-date "2024-01-01..2024-12-31"

3. Quoting Rules

Multi-word search:

gh search commits "bug fix"

Date comparisons need quotes:

gh search commits "refactor" --author-date "<2024-06-01"

Common Use Cases

Find commits by author:

gh search commits --author octocat --repo cli/​cli

Search commit messages:

gh search commits "security fix" --repo myorg/​myrepo

Find commits in date range:

gh search commits "refactor" --author-date "2024-01-01..2024-12-31"

Find merge commits:

gh search commits --merge --repo owner/​repo

Exclude bot commits:

gh search commits -- "deployment -author:dependabot"

Search by commit hash:

gh search commits --hash 8dd03144

Find commits by email:

gh search commits --author-email [email protected]

Common Mistakes

MistakeProblemFix
--author="NOT bot" or --committer=-userFlag syntax doesn't support negationUse query: -- "-author:bot" or -- "-committer:user"
gh search commits fix -author:bot-author interpreted as flagUse --: -- "fix -author:bot"
"deploy NOT author:bot"NOT keyword doesn't workUse -: -- "deploy -author:bot"
Mixing syntaxes: --author octocat "fix -committer:bot"Can't mix flags with query qualifiersUse query for all: -- "fix author:octocat -committer:bot"
--author-date 2024-01-01 without comparisonMay not work as expectedUse: --author-date ">2024-01-01"
Not quoting date comparisonsShell interprets operatorsQuote: "<2024-06-01"
--author @octocatInvalid @ prefixDrop @: --author octocat
PowerShell without --%Breaks with exclusionsAdd: gh --%

Installation Check

If gh command not found:

# Check if gh is installed
which gh

# Install: https://cli.github.com/​manual/​installation

If not authenticated:

# Authenticate with GitHub
gh auth login

Date Comparison Operators

  • > - After date
  • >= - On or after date
  • < - Before date
  • <= - On or before date
  • .. - Date range: 2024-01-01..2024-12-31

Related

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
Imagica logo
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View