Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Searching in multiple Github repositories

Tags:

I Want to search all our codebase in our Github installation for different text strings. We have app. 90 different repositories.

Is there such a method?

I can only find search for file names, authors etc., not search for strings inside code. My task is to find every project which uses or refers to systems, classes, methods etc. that soon are obsolete.

Alternately: Is there a method to download/clone all repositories in one action?

We use SourceTree as client software.

like image 622
Anders Finn Jørgensen Avatar asked Aug 20 '15 13:08

Anders Finn Jørgensen


People also ask

How do I search all repositories in GitHub?

You can search globally across all of GitHub, or scope your search to a particular repository or organization. To search globally across all of GitHub, type what you're looking for into the search field at the top of any page, and choose "All GitHub" in the search drop-down menu.

How do I search multiple topics on GitHub?

You can search for topics on GitHub, explore related topics, and see how many repositories are associated with a certain topic. Navigate to https://github.com/search. Type a topic keyword.

Can I have multiple git repositories?

With Git, using multiple repositories is the only way to work efficiently. This enables each team to work independently, and do their work faster. You can also make sure that developers only have access to the repositories they need access to (thus making Git more secure.)


2 Answers

You can search directly at the top of an Organisation now. This results in the prefix org:.

e.g. if you wanted to search all twitter repos for the word bot you would search for org:twitter bot

https://github.com/search?l=&q=org%3Atwitter+bot&ref=advsearch&type=Code

like image 121
opticyclic Avatar answered Dec 29 '22 00:12

opticyclic


You can search multiple repositories by adding the repo: option to your query, which you can see in action on GitHub's advanced search page. Each repo value takes the usual user/repository form. For example:

find_me repo:me/foo repo:you/bar repo:company/baz 

To make a list of all your repositories if you don't have one, an easy way might be GitHub's repositories API.

Once you have the list, it would also be simple to clone everything with a simple shell script. I don't believe GitHub has a built-in feature for that.

while read repo; do   git clone https://github.com/$repo done < list_of_repos.txt 

Since it sounds like you're pulling an organization's repos, caniszczyk has a Gist doing just that. I'll copy the core of it here, but there's some discussion with updates and help for private repos.

curl -s https://api.github.com/orgs/twitter/repos?per_page=200 | \ ruby -rubygems -e 'require "json"; JSON.load(STDIN.read).each { |repo| %x[git clone #{repo["ssh_url"]} ]}' 

There's also another SO question asking about it, and a full backup script to get issues, wikis, etc.

like image 39
Kristján Avatar answered Dec 28 '22 23:12

Kristján