GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
GH-SEARCH-CODE(1) GitHub CLI manual GH-SEARCH-CODE(1)

gh-search-code - Search within code

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 , and new features like regex search are not yet available via the GitHub API.

Filter on file extension

Filter on filename

Filter JSON output using a jq expression

Output JSON with the specified fields

Filter results by language

Maximum number of code results to fetch

Restrict search to file contents or file path: {file|path}

Filter on owner

Filter on repository

Filter on size range, in kilobytes

Format JSON output using a Go template; see "gh help formatting"

Open the search query in the web browser

path, repository, sha, textMatches, url

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.

# 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

gh-search(1)

Jul 2025

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.