Reputation: 1405
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.
Upvotes: 43
Views: 37789
Reputation: 8154
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
Upvotes: 49
Reputation: 18843
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.
Upvotes: 22