DEV Community

Discussion on: My commit message workflow

 
shreyasminocha profile image
Shreyas Minocha • Edited

Great idea. I'll update the article to use this.

Edit: I just tried this on macOS and it errors out with sed: 1: ".git/COMMIT_EDITMSG": invalid command code .. With some searching, I learnt that BSD sed (the one that macOS uses) requires an extension with -i. However, even that gives me sed: 1: "/^# Please/,+2 d": expected context address. Apparently the +2 thing is GNU sed specific. The first statement (with -i.bak) didn't error, but didn't remove the lines either. I'm guessing it's because of inconsistencies in implementations of sed.

Thread Thread
 
jwmevans_77 profile image
James Evans • Edited

Does the other sed command work for you (sed -i.bak '/\(# Please.*\|# with.*\|^#$\)/ d' $1)?
You can also try this one: sed -i.bak '/^# Please/,/^#$/ d' $1

To keep things tidy you could make it sed -i.bak '/^# Please/,/^#$/ d' $1 && rm $1.bak

Thread Thread
 
shreyasminocha profile image
Shreyas Minocha

Perfect.