Home / Alt manpages / gh-search-repos(1)

  • gh-search-repos(1)
  • User command
  • linux

Hunt Down Repositories with gh search repos

You need a Go library that is still maintained, not one archived three years ago, and GitHub's web search is fighting you. gh search repos gives you repeatable searches with owner, language, topic, activity and archive filters, plus machine-readable output for scripts. The examples use GitHub CLI 2.87.3, installed here on 24 September 2026, and take about ten minutes.

  • You need: gh installed and a network connection.
  • Private results: public searches work as they are, but private or internal results depend on the account and host you are using.
  • Privileges: no command in this guide needs elevated privileges or changes local files.

1. Check the installed command

Confirm the version and read the option list from the same binary that will run your search:

$ gh --version
gh version 2.87.3 (2026-02-23)
$ gh search repos --help

The command is gh search repos [query] [flags]. The default is at most 30 repositories, sorted by best match. A search is read-only: it does not clone, edit, archive or delete a repository.

Checkpoint

If gh --version fails, install GitHub CLI from your distribution's documented package source before troubleshooting search syntax. If the version differs, treat the local help as the authority for its available flags.

2. Search with words and phrases

Separate words are search terms. Quote a phrase so your shell passes it as one argument:

$ gh search repos cli shell --limit 5
$ gh search repos "vim plugin" --limit 5

The first search asks GitHub for repositories matching both words. The second passes one multi-word phrase. Search is not case sensitive. The human-readable output shows repository names and summary details, but the display is not a stable interface for a script.

GitHub's repository search also supports raw qualifiers. Put one in the query when the repository search syntax expresses the condition more directly:

$ gh search repos topic:github 'stars:>5000' --limit 10
$ gh search repos -- -topic:linux --limit 10

The -- before -topic:linux stops option parsing, so the leading hyphen reaches GitHub as a search term.

Warning

Without the separator, a query beginning with a hyphen can be mistaken for a gh option, and this is an easy place to lose time. Quote values containing shell metacharacters, spaces or comparison operators.

3. Add repository filters

Use flags when you want the command's named parameters to describe the search. This finds public repositories owned by an organisation:

$ gh search repos --owner=microsoft --visibility=public --limit 10

For a language and issue signal, use a quoted comparison:

$ gh search repos --language=go --good-first-issues='>=10' --limit 10

Other useful repository filters: --stars, --forks, --followers, --created, --updated, --license, --topic, --number-topics, --size and --match. The last one restricts matching to name, description or readme.

Archived repositories are included unless you say otherwise. Exclude them explicitly when you want an active starting point:

$ gh search repos --archived=false --limit 10

Forks are a separate trap. The --include-forks flag accepts false, true or only. Without an explicit fork choice, do not assume a result set contains every fork. For example:

$ gh search repos --topic=unix,terminal --include-forks=only --limit 10

4. Control ordering and result count

--limit sets the maximum number fetched, not a promise that many exist. Keep it small while refining a query:

$ gh search repos --language=rust --sort=updated --order=desc --limit 5

The installed command supports forks, help-wanted-issues, stars and updated for --sort. --order is ignored unless a sort is selected, and defaults to descending. Omit --sort and you get best match, not an activity ranking.

Checkpoint

Rerun the final query with a deliberately small limit and inspect the names before increasing it. That catches a broad query or a misplaced qualifier without producing a huge response.

5. Request fields for a script

Use --json when another command needs structured data. Ask only for the fields you need:

$ gh search repos --language=go --archived=false --limit 5 \
    --json fullName,description,stargazersCount,url

Available fields include fullName, description, language, license, stargazersCount, forksCount, updatedAt, isArchived, isFork, isPrivate, visibility and url. Run gh search repos --help for the complete list in this installed release.

Pipe JSON to --jq for a simple projection. This prints one tab-separated name and URL per repository:

$ gh search repos --language=go --archived=false --limit 5 \
    --json fullName,url --jq '.[] | [.fullName, .url] | @tsv'

Keep the query, filters and limit explicit in automation. Do not parse the default table output, because presentation can change between CLI releases.

Warning

Treat repository descriptions and names as untrusted text if you pass them into another program.

6. Diagnose an empty or unexpected result

Run the same search with a small limit and no optional filter, then add conditions one at a time. A query can be valid and still return nothing because the owner, language, topic or date condition is too narrow.

Check the usual boundaries:

  • Quotes matter. A phrase in quotes is one term; unquoted words are separate terms.
  • Quote comparisons. Something like >=10 should be quoted so the shell does not reinterpret it.
  • Negative qualifiers. A leading one needs -- before it.
  • Order needs sort. --order has no effect without --sort.
  • Access. A private or internal result requires access through the current GitHub account and host.

To open the query in a browser rather than print results, add --web:

$ gh search repos --topic=terminal --web

Tip

This launches the configured browser, and it is the only example here that deliberately moves the result into another application. On a restricted workstation, leave out --web and use the terminal or JSON output.

Done means

  • Version checked. You confirmed the installed gh version and local flag set.
  • Terms told apart. You can distinguish separate words, quoted phrases and raw qualifiers.
  • Defaults known. The default limit is 30 and the default sort is best match.
  • Archives and forks handled. You can exclude archived repositories and choose how forks are treated.
  • Structured output. You use --json and --jq instead of scraping display output.
  • Narrow filters found. You can isolate a too-narrow filter without changing any repository state.