I need to use the Git log command to extract Commit Id, commit subject where commit-body contains a specific word. I also need to print only those lines from the commit body that contain that word.
Using the command below, I am able to obtain relevant commit Id's and subject, but I can't see the lines from commit body containing the word 'CRs-Fixed'.
git log --pretty=format:"%H,%s" AU_1..AU2 --no-merges --grep='CRs-Fixed'
And If I do git log --pretty=format:"%H,%s,%b" AU_1..AU2 --no-merges --grep='CRs-Fixed',
I get the entire commit body- which I don't need.
Any suggestions on how to get only the desired information?
Tag your header lines as keepers:
git log --pretty=format:$'\001%H\n\001%s\n%b' --grep='CRs-Fixed' \
| sed $'/^\001\\|Crs-Fixed/s/^\001//'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With