GH-SEARCH-COMMITS(1)
π gh-search-commits β bestie's guide to stalking commits β¨
okay so this is gh-search-commits(1), part of the GitHub CLI manual, and it's literally the tool you use to search for commits on GitHub. yes. commits. the little history blobs. we're going digging π
β¨ SYNOPSIS β¨
gh search commits [<query>] [flags]
π¦ DESCRIPTION π¦
So like β this command searches for commits on GitHub. That's it, that's the whole vibe. π
But here's the thing: you can build your search query in three different ways, and you can also mix 'em together because we're flexible like that:
- using the GitHub search syntax directly in your query
- using the parameter and qualifier flags (the long list of options below, bestie)
- or a combination of the two β¨
The GitHub search syntax is documented over at:
https://docs.github.com/search-github/searching-on-github/searching-commits
And if you're out here trying to handle search queries containing a hyphen and it's giving you grief, just run gh search --help β there's more info in there iykyk π«Ά
π OPTIONS π
--author <string>β filter by author π--author-date <date>β filter based on authored date--author-email <string>β filter on author email--author-name <string>β filter on author name--committer <string>β filter by committer--committer-date <date>β filter based on committed date--committer-email <string>β filter on committer email--committer-name <string>β filter on committer name--hash <string>β filter by commit hash-q,--jq <expression>β filter JSON output using a jq expression--json <fields>β output JSON with the specified fields-L,--limit <int>(default30) β maximum number of commits to fetch--mergeβ filter on merge commits--order <string>(default"desc") β order of commits returned, ignored unless '--sort' flag is specified:{asc|desc}--owner <strings>β filter on repository owner--parent <string>β filter by parent hash-R,--repo <OWNER/REPO>β filter on repository, inOWNER/REPOformat--sort <string>(default"best-match") β sort fetched commits:{author-date|committer-date}-t,--template <string>β format JSON output using a Go template; see "gh help formatting"--tree <string>β filter by tree hash--visibility <strings>β filter based on repository visibility:{public|private|internal}-w,--webβ open the search query in the web browser
π JSON FIELDS π
so if you're doing the whole --json thing, these are the fields you can ask for, no cap:
author, commit, committer, id, parents, repository, sha, url
π EXIT CODES π
like, what did the command even do? here's the vibe check:
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, bestie π«Ά
π EXAMPLE π
okay these are the ones you're gonna actually use, so pay attention:
# 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 π§
gh-search(1)β the sibling, go say hi π
that's the whole page, bestie. mwah. this was GitHub CLI v2.102.0, dated Oct 2026, and you can find it under the GH-SEARCH-COMMITS(1) name whenever you need it again. slay π
β¨
π¦ where this page comes from
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- opensuse-leap 16.0: gh 2.102.0-bp160.1.1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms