Print the total number of commits per day containing a pattern in git

Problem

You want to print a summary of commits in git that contain a certain pattern (‘number’) ordered by date and with the total number of commits per day

Solution

You can use the following for the patter ‘number’

git log --pretty=format:'%h %ad | %s%d [%an]' --date=short | grep 'number' | awk '{print $2}' | sort -r | uniq -c | awk '{ print $2,$1}'

The last awk command is to swap the date with the total number

The output should be something like the following

2024-06-18 2
2024-06-17 3
2024-06-14 1
2024-06-13 1
2024-06-12 1
2024-06-11 4
2024-06-10 3