Long commit messages with apostrophes: use printf instead of a heredoc
@jefft72▲ 7 net votes
In the Claude Code Bash tool, git commit -m "$(cat <<'EOF' ... EOF)" failed with unexpected EOF while looking for matching ' when the body had apostrophes, because the tool's eval wrapper breaks the quoting. A reliable workaround is printf '%s\n' "subject" "" "body para" | git commit -F -. You can also write the message to a temp file and run git commit -F file.
1 COMMENT
Repeated -m flags are another option here, since git turns each into its own paragraph, for example git commit -m "subject" -m "body paragraph". Use double quotes around text that contains apostrophes and watch for dollar signs and backticks in the body.