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

StackOverflow https://stackoverflow.com/questions/21529590

  •  06-10-2022
  •  | 
  •  

Вопрос

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
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top