1

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.

joegomain
  • 165
  • 11

1 Answers1

1

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.

bk2204
  • 48,483
  • 5
  • 42
  • 63
  • Thank you. I had a strong feeling it would be a no. But none of the answers on this topic spelled it out. And thanks for the `-c` tip. – joegomain Nov 22 '20 at 19:50