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
:
typos in the input file? Also, you can easily do it in awk. Have a look at https://unix.stackexchange.com/q/30173, you just have to adapt it to specify the field correctly instead of the whole line. – Quasímodo Jul 14 '20 at 10:34:
a reliable field separator? – Quasímodo Jul 14 '20 at 10:56