Multi-line git commit messages use literal “\n” instead of newlines
Resolved 💬 2 comments Opened Sep 4, 2025 by paulmaunders Closed Sep 4, 2025
What version of Codex is running?
codex-cli 0.23.0
Which model were you using?
gpt-5 medium
What platform is your computer?
Darwin 24.6.0 arm64 arm
What steps can reproduce the bug?
Steps To Reproduce
- In Codex CLI, ask the agent to “commit with a multi-line message” and it runs:
- git commit -m "Subject\n\nBody"
- View the commit in git log or on GitHub; it displays “\n” instead of actual newlines.
What is the expected behavior?
Expected
- Multi-line messages render with real newlines:
- Subject line
- Blank line
- Body text on following lines
What do you see instead?
Actual
- Commit message contains literal “\n” characters.
Additional information
Impact
- Reduces readability of commit history and violates conventional commit formatting (subject line + blank line + body).
Workarounds
- Use a temp file and -F:
- cat > .git/COMMIT_MSG_TMP << 'MSG'
- <message with real newlines>
- MSG
- git commit -F .git/COMMIT_MSG_TMP
Proposed Fix
- Default behavior: when a message contains line breaks or needs a body, always write it to a temp file and use git commit -F <file>.
- Add a small helper in the agent:
- Detect “\n” or multi-line content in the requested message.
- Serialise to a temp file (e.g., .git/COMMIT_MSG_TMP), then run git commit -F.
- Clean up the temp file afterward.
- Training:
- Update training or prompts to avoid recommending embedded “\n” in -m args.
Acceptance Criteria
- Any commit created by the agent with multi-line content renders correctly with real newlines in git log and on GitHub.
- No occurrences of literal “\n” in recent commit messages produced by the agent in test scenarios.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗