Git: start commit messages with #

At work we're using gitlab for git repository self-hosting, and also for issue tracking.

Since all features have an issue and thus an issue number, I had our developers to mention them in each commit message:

$ git sl
#23: Add foo
#42: Fix bar

This works fine when passing the commit message on command line with the -m option, but not when git fires up the editor:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
...

Git it using the hash sign as comment indicator, stripping all lines beginning with it - as a result, the commit message will be empty.

I could now add a space in front of every #ticketnumber or change the character that git uses for comments:

$ git config --global core.commentChar ';'

Now git uses a semicolon, which is very fine for us:

; Please enter the commit message for your changes. Lines starting
; with ';' will be ignored, and an empty message aborts the commit.
...

Written by Christian Weiske.

Comments? Please send an e-mail.