﻿---
title: "commit_attribution 只写身份；先开 features.codex_git_commit"
summary: "开关默认关，源码里仍是开发中。打开后才给 Codex 生成的提交加 trailer。键值不要带 Co-authored-by 前缀，空字符串才是关掉。"
category: config
level: intermediate
surfaces: [cli]
tags: ["commit_attribution", "git", "features"]
canonical: /tips/codex-git-commit-attribution/
---

# commit_attribution 只写身份；先开 features.codex_git_commit

开关默认关，源码里仍是开发中。打开后才给 Codex 生成的提交加 trailer。键值不要带 Co-authored-by 前缀，空字符串才是关掉。

`commit_attribution` 单独写了也不会生效。先打开功能，再写身份：

```bash
codex features enable codex_git_commit
codex features list
```

```toml
[features]
codex_git_commit = true

commit_attribution = "Codex <noreply@openai.com>"
```

源码会在前面拼 `Co-authored-by: `。所以键值只写姓名和邮箱，不要再抄一整行 trailer，否则提交信息会变成双重前缀。空字符串 `""` 关掉注入。没写键时，打开开关会用默认身份 Codex 和官方 noreply 邮箱。

这是提示注入，不是 git hook。模型多数时候会听话，但你自己 `git commit -m`、或会话里没走这条提交路径，都不会自动补。不要用会撞上别人 GitHub 账号的公开邮箱。需要硬保证再用仓库自己的 `prepare-commit-msg`。

`codex_git_commit` 在功能表里是 UnderDevelopment，会出现在 `/experimental`。对照本机 `features list`，不要写进全员默认。改完新开会话，让它做一次真正的 git commit，用 `git log -1 --format=%B` 看 trailer。

## 来源

- [OpenAI · Configuration reference](https://developers.openai.com/codex/config-reference)
- [openai/codex#19799](https://github.com/openai/codex/issues/19799)
