codex - 💡(How to fix) Fix Codex still writes literal "\n" into git commit messages instead of real newlines [4 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#18853Fetched 2026-04-22 07:51:29
View on GitHub
Comments
4
Participants
2
Timeline
12
Reactions
0
Author
Timeline (top)
commented ×4labeled ×4closed ×1mentioned ×1

Fix Action

Fix / Workaround

Fedora 43 with all patches applied. Linux 6.19.11-200.fc43.x86_64 x86_64 unknown

Code Example

fixup! some subject

Line one\nLine two\n\nRef: ...

---

fixup! some subject

Line one
Line two

Ref: ...

---

git commit -m "subj" -m "line1\\nline2"

---

line1\nline2

---

git commit -m "subj" -m "line1
line2"

---

line1
line2
RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.122.0

What subscription do you have?

Pro, but why is this relevant?

Which model were you using?

gpt-5.4 high

What platform is your computer?

Fedora 43 with all patches applied. Linux 6.19.11-200.fc43.x86_64 x86_64 unknown

What terminal emulator and version are you using (if applicable)?

No response

What issue are you seeing?

Codex sometimes creates Git commit messages with literal \n sequences in the message body instead of real line breaks.

This is especially painful when Codex uses git commit -m ... -m ... or git commit --amend -m ... -m ... for multiline commit messages.

Example of broken stored commit message:

fixup! some subject

Line one\nLine two\n\nRef: ...

Expected:

fixup! some subject

Line one
Line two

Ref: ...

This has been happening for a long time across multiple Codex sessions.

Related older issue: https://github.com/openai/codex/issues/3094

What steps can reproduce the bug?

  1. Ask Codex to create or amend a Git commit with a multiline body.
  2. Let Codex use a shell command like git commit -m ... -m ....
  3. Inspect the stored commit message with: git log -1 --format=raw or git log -1 --format=%B | cat -vet
  4. Observe literal \n in the message body instead of actual newlines.

What is the expected behavior?

Codex should create proper multiline commit messages with real line breaks.

Additional information

I reproduced the underlying behavior locally:

Bad:

git commit -m "subj" -m "line1\\nline2"

This stores:

line1\nline2

Good:

git commit -m "subj" -m "line1
line2"

This stores:

line1
line2

So this looks like a command-construction/escaping bug in Codex rather than a Git bug. A robust fix would be for Codex to use real newlines or git commit -F <file> for multiline messages.

So far, it has been enough to prompt Codex to fix the newline mess in the created commit. Starting a few days ago, I also need to ask Codex to validate the fix (otherwise, it claims it fixed it, but it actually just recreated the same issue).

extent analysis

TL;DR

Codex CLI may need to properly escape or handle newline characters when constructing Git commit commands to fix the issue of literal \n sequences in commit messages.

Guidance

  • The problem seems to stem from how Codex constructs the git commit command, specifically when using -m for multiline messages. It incorrectly escapes newline characters, leading to \n being stored instead of actual line breaks.
  • To verify the issue, users can follow the steps provided, including inspecting the stored commit message with git log commands.
  • A potential workaround could involve manually editing the commit message after Codex generates it, or prompting Codex to use a different method for creating commit messages, such as using a file with git commit -F.
  • The issue might be mitigated by Codex using real newlines in the command construction instead of escaped newline characters (\n).

Example

No specific code example is provided due to the nature of the issue being related to command line interaction and the specifics of how Codex constructs these commands.

Notes

The exact fix would depend on how Codex's command construction logic can be modified to handle newline characters correctly. The provided information suggests this is a bug within Codex rather than a Git issue.

Recommendation

Apply workaround: Given the information, a robust fix would involve modifying Codex to use real newlines or an alternative method like git commit -F <file> for multiline messages, but until such a fix is implemented, manually editing the commit messages or prompting Codex to validate its fixes seems to be a necessary workaround.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

codex - 💡(How to fix) Fix Codex still writes literal "\n" into git commit messages instead of real newlines [4 comments, 2 participants]