Git shortlog exclude comments starting with string

304 views Asked by At

I am trying to count the commits by each author but like to exclude commits whos messages begin with the word TEST.. for example.

I am currently doing the following to get the list.

 git shortlog -s -n --all

This brings back my counts but drilling into each authors commits shows a lot which start with TEST.. I would like to get the count without these commits included.. is this possible?

1

There are 1 answers

0
Joseph K. Strauss On

The following one-liner will work. I am using Git Bash, which is up to version 1.9.4.

git shortlog $(git log --pretty=format:"%H %s" | grep -v 'stuff' | cut -c -40) --no-walk

If you have a later version that accepts the --invert-grep option you can probably use the following. (I noticed that shortlog seems to take all the same arguments as log, but it is undocumented.) I cannot test this though.

git shortlog --grep 'stuff' --invert-grep