Using Git, how could I search for a string across all branches?

前端 未结 5 2048
一个人的身影
一个人的身影 2020-12-22 15:25

Using Git, how could I search within all files in all local branches for a given string?

GitHub specific: is it possible to perform the above search across all GitHu

5条回答
  •  抹茶落季
    2020-12-22 16:12

    You can do this on a Git repository:

    git grep "string/regexp" $(git rev-list --all)
    

    GitHub advanced search has code search capability:

    The code search will look through all of the code publicly hosted on GitHub. You can also filter by:

    • the language: language:
    • the repository name (including the username): repo:
    • the file path: path:

提交回复
热议问题