I have a Git repository that contains hundreds of commits and several branches. How to search a particular commit that contains a certain string e.g. "helper function"? Ideally, the string can be denoted by a regex.
2 Answers
Newer versions of Git support git log -G<regex>:
git log -G'helper.*function' --full-history --all
This command will search for the regex in the diff of each commit, and only display commits which introduced a change that matches the regex.
1 Comment
Eosis
This was the answer I was looking for, and how I understood the question was written.
Credits go to this answer:
git log --all --grep='Build 0051'
# case insensitive
git log --all --grep='Build 0051' -i
1 Comment
staafl
This looks for the regex in the commit message as opposed to knittl's answer, where -G<regex> searches through the commit's diff.