user2689092
user2689092

Reputation: 383

Search all Git repositories in a GitHub organization for a pattern

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.

Upvotes: 16

Views: 21211

Answers (4)

Nick
Nick

Reputation: 1

For those using GitHub organization:

https://your-company-organization/search?q=term-you-want-to-search-for

e.g.

https://your-company-organization/search?q=kebab

This will search across the GitHub organisation to find any relevant matches, including repositories and code.

Upvotes: -6

Jonny Rimek
Jonny Rimek

Reputation: 1171

type org:ORGNAME searchvalue in the search field, this will restrict the search to every repo in ORGNAME

Upvotes: 2

Heiko Voigt
Heiko Voigt

Reputation: 1

Please note that GitHub search only indexes repositories that have been active in the last year. See https://github.blog/changelog/2020-12-17-changes-to-code-search-indexing/

So if you really want to be sure to search everything in your org it might make sense to consider setting up something for the org manually like hound:

https://github.com/hound-search/hound

Upvotes: 0

Chris
Chris

Reputation: 137084

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.

Upvotes: 23

Related Questions