Use of apostrophe (single-quote) in a Git commit message via command line

There is no need to escape the ' character if your commit is double quoted.

git commit -m "cracked enigma's code"

EDIT: Anyway, when you have some special characters to add in the commit message I prefer to edit in a editor (like nano or vim), commiting without the -m option.

git commit

And then put the message and exit. It's more confortable instead of thinking how you have to escape all those quotes and double quotes.


Use double quotes:

git commit -m "cracked enigma's code"

Or, if your message contains other special characters, use double quotes or backslash only for the single quote:

git commit -m 'cracked $enigma'"'"'s code'
git commit -m 'cracked $enigma'\''s code'

Tags:

Escaping

Git

Bash