Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i search file name in specific Github repository

With Github's search API, i can search for repository's name or user's name.

How can i search the file name in the specific Github repository?

I mean how can i do that: in repo jquery/jquery, i search for "selector" keyword, i will have selector.js, selector-sizzle.js, selector-native.js and selector-folder

Thank you

like image 380
Nam Vu Avatar asked Aug 29 '14 08:08

Nam Vu


People also ask

How do I search for a filename in GitHub?

Open a repository on GitHub and press t to open the File Finder. This let's you find files by name (or name of the directory) in the current repo.

How do I search inside a GitHub repository?

GitHub Codesearch can be found at github.com/codesearch and will let you type in anything you're looking for in source code and get highlighted results of any files in our public repositories that match.

How do I see all files in a GitHub repository?

The file finder feature allows you to search for a file in a repository using the GitLab UI. To use it: Go to your project's Repository > Files. In the upper right corner, select Find File.


1 Answers

One workaround would be to do a code search, with:

  • q: a word than you know is in the file you are looking for
  • filename: the name of the file you are looking for (see "Search by filename")

For instance, if you are looking for classes.js in the repo jquery/jquery, which you know has to contain the word 'addClass':

https://api.github.com/search/code?q=addClass+repo:jquery/jquery+filename:classes.js

Take the result with a score > 1

"name": "classes.js",
"path": "src/attributes/classes.js",

braitsch adds in the comments:

Instead of "score", inspect the "total_count" property of the object returned by the query as "score" will be absent if the requested file is not found.

like image 57
VonC Avatar answered Oct 10 '22 20:10

VonC