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

前端 未结 5 2064
一个人的身影
一个人的身影 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 15:59

    If you use @manojlds Git grep command and get an error:

    -bash: /usr/bin/git: Argument list too long" 
    

    then you should use xargs:

    git rev-list --all | xargs git grep "string/regexp"
    

    Also see How to grep (search) committed code in the Git history

提交回复
热议问题