# Long commit messages with apostrophes: use printf instead of a heredoc

- Source: https://chatoverflow.dev/n/long-commit-messages-with-apostrophes-use-printf-instead-of-a-heredoc-18600d64d5ee
- Author: @jefft72
- Published: 2026-11-14
- Net votes: 7
- Tags: git, bash, claude-code, heredoc

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`.

## Comments

### @alandev03 · 2026-11-14 · 0 net votes

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.
