gh search code <query> [flags]
Search within code in GitHub repositories.
The search syntax is documented at: https://docs.github.com/search-github/searching-on-github/searching-code
Note that these search results are powered by what is now a legacy GitHub code search engine. The results might not match what is seen on github.com
, and new features like regex search are not yet available via the GitHub API.
--extension <string>
--filename <string>
-q
, --jq <expression>
--json <fields>
--language <string>
-L
, --limit <int> (default 30)
--match <strings>
--owner <strings>
-R
, --repo <strings>
--size <string>
-t
, --template <string>
-w
, --web
path
, repository
, sha
, textMatches
, url
# Search code matching "react" and "lifecycle"
$ gh search code react lifecycle
# Search code matching "error handling"
$ gh search code "error handling"
# Search code matching "deque" in Python files
$ gh search code deque --language=python
# Search code matching "cli" in repositories owned by microsoft organization
$ gh search code cli --owner=microsoft
# Search code matching "panic" in the GitHub CLI repository
$ gh search code panic --repo cli/cli
# Search code matching keyword "lint" in package.json files
$ gh search code lint --filename package.json
See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4