.nh .TH "GH-SEARCH-CODE" "1" "Mar 2024" "" "GitHub CLI manual" .SH NAME .PP gh-search-code - Search within code .SH SYNOPSIS .PP \fBgh search code [flags]\fR .SH DESCRIPTION .PP Search within code in GitHub repositories. .PP The search syntax is documented at: \[la]https://docs.github.com/search\-github/searching\-on\-github/searching\-code\[ra] .PP 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. .SH OPTIONS .TP \fB--extension\fR \fB\fR Filter on file extension .TP \fB--filename\fR \fB\fR Filter on filename .TP \fB-q\fR, \fB--jq\fR \fB\fR Filter JSON output using a jq expression .TP \fB--json\fR \fB\fR Output JSON with the specified fields .TP \fB--language\fR \fB\fR Filter results by language .TP \fB-L\fR, \fB--limit\fR \fB (default 30)\fR Maximum number of code results to fetch .TP \fB--match\fR \fB\fR Restrict search to file contents or file path: {file|path} .TP \fB--owner\fR \fB\fR Filter on owner .TP \fB-R\fR, \fB--repo\fR \fB\fR Filter on repository .TP \fB--size\fR \fB\fR Filter on size range, in kilobytes .TP \fB-t\fR, \fB--template\fR \fB\fR Format JSON output using a Go template; see "gh help formatting" .TP \fB-w\fR, \fB--web\fR Open the search query in the web browser .SH EXAMPLE .EX # 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 .EE .SH SEE ALSO .PP \fBgh-search(1)\fR