Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Search all Git repositories in a GitHub organization for a pattern

Tags:

git

github

I have a GitHub organization. There are about 250 repositories belonging to different teams in this organization. I have admin access to the organization account. Is there a way I can use to search for a pattern in all these repositories, ideally via GitHub's web interface?

We are planning to update some .jar file locations, but we need to know which code in these repositories is using the old locations.

like image 504
user2689092 Avatar asked Apr 16 '18 16:04

user2689092


People also ask

How do I retrieve all GitHub repositories of an organization?

Hitting https://api.github.com/users/USERNAME/repos will list public repositories for the user USERNAME. Show activity on this post. to find all the user's repos.

How do I search for a file in GitHub organization?

Of course, just do "filename:the-file-name" if you want to search the whole of GitHub. This is now documented on Github.

Can you grep on GitHub?

The `git grep` is a useful command for searching the specific content in the git repository. The searching can be done in different ways by using the different options of this command.


Video Answer


1 Answers

This is on a GitHub org within my company. I want to search at the org level from my browser or something like that since it can be painful to go through the 250 repos under this org.

If you navigate to your organization page

https://github.com/<organizationName>

you should see a search box in the header:

GitHub organization search

Once you submit a search, you may see on the main panel “ We couldn’t find any repositories matching 'organizationName query’”.

But you can switch from a repository search to a Code search using the side navigation bar:

GitHub search types

This should build a URL something like

https://github.com/search?q=org%3A<organizationName>+<query>&type=Code

that finds instances of <query> in repositories owned by your organization.

like image 82
Chris Avatar answered Oct 21 '22 13:10

Chris