GH-SEARCH-COMMITS(1) GitHub CLI manual GH-SEARCH-COMMITS(1)

# [NAME](#NAME)

gh-search-commits - Search for commits

# [SYNOPSIS](#SYNOPSIS)

**gh search commits \[&lt;query&gt;] \[flags]**

# [DESCRIPTION](#DESCRIPTION)

Search for commits on GitHub.

The command supports constructing queries using the GitHub search syntax, using the parameter and qualifier flags, or a combination of the two.

GitHub search syntax is documented at:

⟨https://docs.github.com/search-github/searching-on-github/searching-commits⟩

For more information on handling search queries containing a hyphen, run **gh search --help**.

# [OPTIONS](#OPTIONS)

[**--author** **&lt;string&gt;**](#author)

Filter by author

[**--author-date** **&lt;date&gt;**](#author_date)

Filter based on authored date

[**--author-email** **&lt;string&gt;**](#author_email)

Filter on author email

[**--author-name** **&lt;string&gt;**](#author_name)

Filter on author name

[**--committer** **&lt;string&gt;**](#committer)

Filter by committer

[**--committer-date** **&lt;date&gt;**](#committer_date)

Filter based on committed date

[**--committer-email** **&lt;string&gt;**](#committer_email)

Filter on committer email

[**--committer-name** **&lt;string&gt;**](#committer_name)

Filter on committer name

[**--hash** **&lt;string&gt;**](#hash)

Filter by commit hash

[**-q**, **--jq** **&lt;expression&gt;**](#q)

Filter JSON output using a jq expression

[**--json** **&lt;fields&gt;**](#json)

Output JSON with the specified fields

[**-L**, **--limit** **&lt;int&gt; (default 30)**](#L)

Maximum number of commits to fetch

[**--merge**](#merge)

Filter on merge commits

[**--order** **&lt;string&gt; (default "desc")**](#order)

Order of commits returned, ignored unless '--sort' flag is specified: {asc|desc}

[**--owner** **&lt;strings&gt;**](#owner)

Filter on repository owner

[**--parent** **&lt;string&gt;**](#parent)

Filter by parent hash

[**-R**, **--repo** **&lt;OWNER/REPO&gt;**](#R)

Filter on repository, in OWNER/REPO format

[**--sort** **&lt;string&gt; (default "best-match")**](#sort)

Sort fetched commits: {author-date|committer-date}

[**-t**, **--template** **&lt;string&gt;**](#t)

Format JSON output using a Go template; see "gh help formatting"

[**--tree** **&lt;string&gt;**](#tree)

Filter by tree hash

[**--visibility** **&lt;strings&gt;**](#visibility)

Filter based on repository visibility: {public|private|internal}

[**-w**, **--web**](#w)

Open the search query in the web browser

# [JSON FIELDS](#JSON_FIELDS)

**author**, **commit**, **committer**, **id**, **parents**, **repository**, **sha**, **url**

# [EXIT CODES](#EXIT_CODES)

0: Successful execution

1: Error

2: Command canceled

4: Authentication required

NOTE: Specific commands may have additional exit codes. Refer to the command's help for more information.

# [EXAMPLE](#EXAMPLE)

```
# Search commits matching set of keywords "readme" and "typo"
$ gh search commits readme typo
# Search commits matching phrase "bug fix"
$ gh search commits "bug fix"
# Search commits using raw search qualifiers as separate arguments
$ gh search commits fix author:monalisa merge:false
# Search commits committed by user "monalisa"
$ gh search commits --committer=monalisa
# Search commits authored by users with name "Jane Doe"
$ gh search commits --author-name="Jane Doe"
# Search commits matching hash "8dd03144ffdc6c0d486d6b705f9c7fba871ee7c3"
$ gh search commits --hash=8dd03144ffdc6c0d486d6b705f9c7fba871ee7c3
# Search commits authored before February 1st, 2022
$ gh search commits --author-date="<2022-02-01"
```

# [SEE ALSO](#SEE_ALSO)

[**gh-search(1)**](/man/os/gh/gh-search.1)

Oct 2026

---

Document: gh-search-commits(1) from gh 2.103.3-r0 (Chainguard OS)
Source: https://github.com/cli/cli
