解决合并冲突

MVPavan2026-10-27查看 1641复制 121

当 git merge、rebase 或 cherry-pick 已处于冲突状态且需要解决冲突时使用。在出现 merge-conflict / rebase-conflict 相关表述时触发。

Download (.md)

📘如何使用这个技能

  1. 1
    复制技能内容·点击上方「Copy SKILL.md」复制全部内容,或 Download 下载到本地
  2. 2
    打开你的 AI 客户端·支持 Claude Code、Trae、Cursor、ChatGPT、DeepSeek、Kimi 等任意 AI 助手
  3. 3
    粘贴为系统提示/知识文件·Claude Code:放入 .claude/skills/ 目录;普通对话:作为首条消息发送并说「请严格按这份技能文档执行」
  4. 4
    直接提出你的需求·AI 会按技能定义的工作流、格式和约束来处理,无需再解释背景

💡 提示:技能生效后,每次对话只需一句需求,AI 会按 SKILL.md 的流程执行。

SKILL.md1480 chars
---
name: resolving-merge-conflicts
description: Use when a git merge, rebase, or cherry-pick is already in a conflicted state and the conflicts need resolving. Trigger on merge-conflict / rebase-conflict phrases.
---

1. **See the current state** of the merge/rebase. Check git history, and the conflicting files — capture the conflict set now: `git diff --name-only --diff-filter=U`.

2. **Find the primary sources** for each conflict. Understand deeply why each change was made, and what the original intent was. Use commit messages and relevant requirements first; expand to PRs/issues only
   when a disputed hunk needs that history.

3. **Resolve each hunk.** Preserve both intents where possible. Where incompatible, pick the one matching the merge's stated goal and note the trade-off. Do **not** invent new behaviour. Resolve rather than reflexively aborting; if the two intents cannot be reconciled, or the merge/rebase itself turns out to be the wrong operation, stop and ask the user before `--abort`.

4. Discover the project's **automated checks** and run them — typically typecheck, then tests, then format. Fix anything the merge broke.

5. **Finish the merge/rebase.** Stage only the resolved conflict files, explicitly by path — the list captured in step 1, never `git add .` / `-A`. Commit (or `rebase --continue`) only if the user or the active workstream granted commit authority; otherwise stop with the resolution staged and report what would be committed.
来源:skillsdirectory

评论0

登录后参与评论

还没有评论,来抢沙发吧