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> (default 30) β€” 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, in OWNER/REPO format
  • --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 🧚


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