How to: find string in GitHub repo?

11,137

Solution 1

I'd clone the repo (which you'd need to do anyway if you want to create a PR for it) and git grep it:

$ git grep string_to_look_for

Solution 2

From GitHub Developer Guide:

GET /search/code

Example:

https://api.github.com/search/code?q=addClass+in:file+language:js+repo:jquery/jquery

Solution 3

You can search an entire repo in github by using the search bar found at the top left corner of the screen.

enter image description here

Share:
11,137
Peter David Carter
Author by

Peter David Carter

Normalised to 2nd abnormal form

Updated on July 24, 2022

Comments

  • Peter David Carter
    Peter David Carter almost 2 years

    I'm searching a fairly major GitHub repo for an error that's a) a big one b) easily fixed. I know where it is from the frontend, I just need to search the entire GitHub repo for a string.

    How do I do that?

  • Peter David Carter
    Peter David Carter over 6 years
    no need for git [etc] | grep [etc], nice, will try
  • BartoszMiller
    BartoszMiller over 2 years
    Great answer. Thanks.
  • Mark Jeronimus
    Mark Jeronimus about 2 years
    That doesn't search only strings. That searchers everything, including code, comments, and text files.
  • nikki ricks
    nikki ricks about 2 years
    You're right. It does filter it for you by categories though. So after you search you could then click on "code" if you're wanting it to just be code.