Skip to content

无到提交

错误信息

                无到提交, 工作树 clean
              

快速摘要

你 tried 到提交, 但那里是否 staged 更改 — 你的工作树 matches 最后提交.

为什么发生

  • 你 forgot 到运行 git 添加之前 committing

  • 你 already committed 这些更改

  • 你有否修改, staged, or untracked files

最小示例

✗ 错误代码
git commit -m "Update"  # nothing to commit, working tree clean
✓ 修复代码
git add .
git commit -m "Update"  # now succeeds

你必须 stage 更改使用 git 添加之前 committing. 不使用 staged 更改, 那里是无到提交.

如何诊断

  • 运行 git 状态到 see 如果那里是任何更改到 stage

  • 检查如果 files 你 expect 是 listed as 修改 or untracked

  • 验证你是 on 正确分支

如何修复

  • 运行 git 添加 <file> (or git 添加 .) 到 stage 更改之前 committing

  • 如果你 already committed, 检查 git log 到验证

  • 如果你有否更改, 那里是无到 fix — 消息是 informational

如何预防

  • 总是运行 git 状态之前 git 提交到验证那里是 staged 更改

  • Use git 添加 and git 提交 in 序列

相关资源

相关术语

相关课程

← 返回语言