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

This question already has an answer here:

  • How to escape single quotes within single quoted strings?

    18 answers

  • How to Bash Script Git Local Branch Check?
  • How to execute git commands from bash script?
  • Get Git repo url using absolute path
  • How to check if a repo exists?
  • git commands not respecting io redirection
  • Script bash that restart PlayFramework 2 instance after a push to git?
  • How to check status of remote Git repository?
  • Do I need bcsymbolmap files created by Carthage
  • Does git change unmodified and uncommited files in merge?
  • How to make individual pull requests vs “stacking” them on top of each other in Github?
  • git: how to move some commits to new branch
  • Detach (move) subdirectory into separate Git repository
  • 2 Solutions collect form web for “Use of apostrophe (single-quote) in a git commit message via command line?”

    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'

    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.

    Git Baby is a git and github fan, let's start git clone.