I wouldn't process the "default" log, ever.
You can get halfway there just with a different log format. In this case printing the Hash and Commit message only.
git log --pretty=format:'%H %s' And then use awk to finish up (making the assumption that ticket refs appear at the start of the commit message)
git log --pretty=format:'%H %s' | \ awk -F"[^a-zA-Z0-9]" '$2"-"$3 ~ /^[A-Z]+-[0-9]+$/ {print $2"-"$3":"$1}' Explaining that awk:
-F"[^a-zA-Z0-9]" Everything that isn't alpha or numeric is a field delimiter
$2"-"$3 ~ /^[A-Z]+-[0-9]+$/ In cases where field 2 and 3 (first two "words" of the commit message) look like they are probably a ticket ref, we continue
{print $2"-"$3":"$1} Print the first 3 fields in the desired order.
More robust alternative, based heavily on Ed Morton's answer (adapted lightly for the simpler custom log format):
git log --pretty=format:'%H %s' \ | awk -v OFS=: \ ' match($2, /^[[:upper:]]+-[[:digit:]]+/) { print(substr($2, 1, RLENGTH), $1) } '