← Claude Code 深度指南:从安装到团队协作 · 目录
第 7 / 12 章

7. Git 协作:让 Claude Code 的每一步都有记录

Claude Code 很适合长期协作,但长期协作必须配 Git。每次任务开始前先确认工作区干净:

git status

新任务新分支:

git checkout -b ai/fill-guides

Claude Code 完成后:

git diff
git add .
git commit -m "docs: fill guide chapters"

如果它改坏了:

git restore .

如果你要让 Claude Code 自己提交,也要先让它说明提交内容:

请根据当前改动生成一个 commit message,但不要执行 git commit。先给我看。

不要让 AI 在你没看 diff 的情况下直接 push 到生产分支。AI 写代码快,犯错也快;Git 是你的保险。

广告位 · 指南章节页