joegomain
joegomain

Reputation: 864

Is it possible to escape the hash(#) comment charactor in git commit messages?

Every once in a while I want to include lines that start with # in git commit messages.

The question is "Is there a way to escape the # character so that it is not interpreted as a comment mark?"

Please answer with "Yes, it is.." or "No".

This is not a duplicate of Start a git commit message with a hashmark (#). I simply want a confirmation of whether it is possible to escape or not.

Upvotes: 7

Views: 2599

Answers (1)

bk2204
bk2204

Reputation: 76609

No, it isn't possible to escape the character. If the comment character is #, and you write \#, then your commit message will contain the literal text \#.

If you need to use a different character, you can set core.commentchar to a different value. This can be done on the command line with something like git -c 'core.commentchar=;' commit.

Run this to make it a permanent preference:

git config --global --add core.commentchar ';'

Upvotes: 8

Related Questions