0

I am trying to clean up my git log from duplicate lines. Unfortunately, developers don't use rebase command, and due this there are many duplicate commit massages in git log.

Git log with duplicates lines

TASK-1: awe
TASK-1 : aaa
TASK-1: aaa bbbb   
TASK-2: aaaaa
TASK-3: 123
TASK-3 : 123 aaa 

I need to keep first line with TASK-number and all others lines remove from git log with the same TASK-number

Expected result

TASK-1: awe
TASK-2: aaaaa   
TASK-3: 123

I try to use sort to get uniq commits

git log --pretty=format:"%s  " --no-merges | grep -oP --regexp="TASK-\K\d+" | sort -r | uniq

And this one working so I get only TASK numbers with out commit massages.

1
2
3

But when I change regex extension to --regexp=“^[TASK-]\^*.*” it prints all line.

Can some one help me to remove duplicates line please

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255

0 Answers0