Archived post: posted sometime between 2016 and 2022.

Finding (searching for) things with Git

Search file name

git ls-files '<pathspec>'
git log '<pathspec>'
git rev-list --all -- '<pathspec>'

Search file content

git log -S '<query>'
git log -L '<query>'
git grep '<query>'

Search commit metadata

git log --grep='<query>'
git log --author=name

See also

https://www.git-scm.com/docs/git-log
https://git-scm.com/docs/git-grep
https://git-scm.com/docs/gitglossary.html#gitglossary-aiddefpathspecapathspec