gitで特定なキーワードをソースコードから検索する

gitにはたくさんのブランチがあり、特定のブランチのソースコードに対してキーワードの検索が簡単ですが、すべてのブランチに対して検索することが難しい。

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

には検索の仕方が書かれています。

git grep "キーワード" $(git rev-list --all)

を実行するだけです。自分の環境では

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

とのエラーが発生するため、

git grep "キーワード" $(git rev-list --all | head -n xxxx | tail -n 500 )

のように500件ずつ検索していました。

上記の参考リンクに

git rev-list --all | xargs git grep "キーワード"

との書き方があるが、自分の環境では

error: Out of memory, malloc failed

が発生した。