What you have is a shell quoting issue rather than a git issue. The way to test these out in general is to use the echo
command to see what works.
Some details depend somewhat on which shell you use (the exact quoting mechanisms are different in sh, bash, tcsh, zsh, etc). As you discovered, the rule of thumb is to quote single quotes with double quotes, and vice versa, but this fails when there's nesting.
A demonstration:
$ echo 'STAGED:ONE-419 - The "text" isn\'t blue'
> '
STAGED:ONE-419 - The "text" isn\t blue
$
Clearly not quite right. On the other hand:
$ echo 'STAGED:ONE-419 - The "text" isn'"'t blue"
STAGED:ONE-419 - The "text" isn't blue
$
The single quote sequence ended at the close single quote, and then I used double quotes to quote the rest of it, including the single quote you wanted carried through.
Programmatically, it may be easier to use double quotes:
$ echo "STAGED:ONE-419 - The \"text\" isn't blue"
STAGED:ONE-419 - The "text" isn't blue
$
Double quotes are "less strong" than single quotes, so backslashes work inside them to protect against things double quotes don't protect against: $
-expansion, backquotes, backslashes, and more double quotes. This does mean you need to put backslash in front of each such character:
$ echo "this \$works"
this $works
$ echo "but this $doesn't"
but this 't
$
so it's a bit clumsier, but easy enough to code in most programming languages.