简体   繁体   中英

Search through all git commits with a grep and then format the results

How do I search through all git commits with a grep and then format the results with just the commit hash and the commit notes.

I have tried something like this.

git log --pretty=format:%H %N --grep=mysearchtext

Not sure if I am missing some command pipes somewhere.

Assuming you're talking about the commit message and not the notes , you don't want to use %N . Perhaps %s would be better, or %s %b . That's up to you. Also, make sure you single or double quote the --pretty flag so it's not split into two arguments

git log "--pretty=format:%H %s" --grep=mysearchtext

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM