all of my git commit messages start with
refs #SOME_NUMBER
where SOME_NUMBER is a number from 1 up. I would like to parse all commmit messages on
my working branch, store all of the SOME_NUMBERs in a list, remove duplicates, and save to file. Not really sure where to start….
You can do that pretty easily with this shell one-liner:
Explanation:
git log --format=%sdisplays the first line of every commit messagecut -f 2 -d ' 'splits the line by a space, and prints the second part of the (the#SOME_NUMBERportion)sed 's/#\(.*\)/\1/'removes the number sign from the numbersortsorts the entries in ascending numerical orderuniqensures that each number is only printed once> refs.txtprints the output to a file calledrefs.txt.