Search and filter code on github

3 min read  •  8 Dec 2022
view-count

While developing and writing code, we often come across issues/errors and we look for help on stackoverflow. Sometimes we are not sure of the implementation of a library, or the structure of a file. In those cases, it is helpful to have a look over someone's code on github who has already done it. This post will share some filters which can enhance your searches on github.


Following are the filters which you can use in your github search-

  1. By filename
  2. By term in filename
  3. By multiple term in filename
  4. By extension
  5. By username
  6. By organisation
  7. By repository

By filename

If you want to search for a particular filename on github, you can use this filter.

For eg: If I have to search for lighthouserc.json file, I can search for this specific file on github search as follows

filename:lighthouserc.json
filename-filter

By term in filename

If you want to search for a particular term in a particular filename, you can use the following filter.

For eg: If I have to search for lint-staged in package.json file, I can search it as follows

filename:package.json lint-staged
term-in-filename

By multiple terms in filename

If you want to search for a set of terms in a particular filename, you can add the terms space separated.

For eg: If I have to search for lint-staged and prettier in package.json file, I can search it as follows

filename:package.json lint-staged prettier
multiple-term-in-filename

By extension

If you want to filter your search and limit it to a particular extension.

For eg: Suppose, I have to check types for react, I can filter out files having ts extension and say React.FC as term

extension:ts React.FC
extension-filter

By username

If you want to filter and limit your search results to a particular user.

For eg: Suppose, I have to search my (akulsr0) Next.js projects. I can filter my search with username as akulsr0, filename as package.json containing next

user:akulsr0 filename:package.json next
username-filter

By organisation

If you want to filter and limit your search results to a particular organisation.

For eg: Suppose, I have to search google's project using react, I can filter my search with organisation as google, filename as package.json containing react

org:google filename:package.json react
org-filter

By repository

If you have to filter results and limit them to a particular repository.

For eg: Suppose, I have to check all shell script files in react's codebase. I can filter my search with extension as sh and repository as facebook/react

extension:sh repo:facebook/react
repo-filter