To search within commits text, we use git log -G SEARCHTERM. This lists the commit hash and commit message.
Is there a way to show results like with grep, showing the SEARCHTERM within context?
CodePudding user response:
A pretty close thing is to add -p :
git log -p -G SEARCHTERM
When you combine -p with -G, git will only display the files where SEARCHTERM was found.
For those files, it will display the complete diff though, rather than just the chunks where SEARCHTERM appeared.
CodePudding user response:
Yes, add the -p option.
See https://git-scm.com/docs/git-log#_diff_formatting:
By default,
git logdoes not generate any diff output. The options below can be used to show the changes made by each commit.[…]
-p -u --patchGenerate patch (see section on generating patches).
Which refers to https://git-scm.com/docs/git-log#_generating_patch_text_with_p
