Search a whole Git repository
Sebastian Wright
I'm looking for a tool that lets me perform a search through a complete Git repository (all branches). Ideally that tool would take some search pattern and would return a list of commit objects where that pattern appears (either in the file diffs or in the commit message [ I'm more interested in searching for the pattern in the commit messages than in the files]).
1 Answer
For searching commit messages, use git log --grep <regex> [branches].
For searching commit diffs, use git log -G <regex> [branches].
To specify all existing local branches, use --all in place of the branch name.
If you want only a list of hashes, use --format=%H.