Reputation: 29389
I know that the GitHub web interface lets you search all repositories for files with a particular pathname (e.g. searching for path:/app/models/user.rb
yields > 109k results), but is there a way to search all repositories for filenames independent of their subdirectory location? I tried using asterisks in the path
argument, and that didn't seem to work.
Upvotes: 266
Views: 193624
Reputation: 8497
GitHub introduced FileFinder in 2011.
Try it out: just hit t on any repo's file or directory view.[1]
So, You're still restricted to repository.
[1]https://github.com/blog/793-introducing-the-file-finder
Another approach to Your question:
Can I use Git to search for matching filenames in a repository?
EDIT: as of 2024 GitHub do seem to provide a way to search for a filename, despite the folder structure of the repository. Please check the "advanced search" section. It do seem to boil down to something like the following: https://github.com/search?q=path%3A**%2Ftest.c&type=code&ref=advsearch
Or rather q=path:**/test.c
as it's query argument.
Upvotes: 38
Reputation: 17408
I would like to clarify @ajain's answer regarding accessing files in a Github repository via the web UI. Here are the steps:
More shortcuts for source code browsing.
Upvotes: 21
Reputation: 5491
I had the same problem and I followed GH suggestion to add asterisks for a path search:
path:**/user.rb
Upvotes: -1
Reputation: 391
What works for me is:
path:<filename>
To search for pyproject.toml
file you would use
path:pyproject.toml
Upvotes: 2
Reputation: 5702
As of recently, you should simply use path:user.rb
. This will find files with the name anywhere inside repositories.
Note: The older approaches like file:user.rb
and in:path user.rb
seem to not work anymore.
Upvotes: 3
Reputation: 13207
In my case, I wanted to search for a particular file name, in all of my organization's repositories. This can be done by entering this in the search box:
org:your-organization-user-name filename:the-file-name
Of course, just do "filename:the-file-name" if you want to search the whole of GitHub.
This is now documented on Github.
Upvotes: 24
Reputation: 510
Just press T in the repository's directory view and it will let you search for a file.
Upvotes: 2
Reputation: 747
Upvotes: 0
Reputation: 166359
In search input, you can use filename
parameter to search in multiple repositories, for example:
filename:my_filename.txt
If you're looking for a filename in specific repository, you can just press t and start typing the file name (see: GH keyboard shortcuts).
Upvotes: 111
Reputation: 4090
Does the search user.rb in:path
do what you want to do?
Alternatively there is also this search filename:user.rb
Found on: https://help.github.com/articles/searching-code/
Upvotes: 246
Reputation: 1216
I refined @andy-lester answer with intitle:
, i.e. I want to find where's located the file simple_spinner_item.xml
in Android's source code hosted on github, so I search on Google this string:
site:github.com intitle:simple_spinner_item.xml github.com/android
^ ^ ^
| | |
on github site | |
| |
filename I'm searching -+ |
|
github user ------------------------------------+
Upvotes: 7
Reputation: 93636
You can try Google. Google for filename.txt site:github.com
.
Upvotes: 10