merge-resolve-conflicts
它能做什么
它指导 AI 智能体用默认分支更新你的工作分支,并解决冲突。适用于在 git 分支或工作树上工作的开发者。
适用场景
- ✓当你的分支落后于 main,并想合并最新更改时。
- ✓当 git 报告合并冲突,需要你帮忙解决时。
- ✓当你有未保存的更改,需要决定如何暂存或提交后再合并时。
技能链接
https://github.com/humanlayer/humanlayer/blob/main/.claude/skills/merge-resolve-conflicts/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请把 main 的最新内容合并到我的分支中,并帮我修复所有冲突。”
每周 5 个新技能,1 分钟读完。
工作原理
智能体会获取最新更改,检查你分支的状态,并在触碰未保存的工作前先询问。然后它会和你一起处理这些冲突。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
You are either on a branch in a repository, or you are on a git worktree for a specific branch.
You are responsible for ensuring the default branch (usually main or master, but not always) is merged into the current branch.
Begin by running git fetch.
Then:
Step 1: Orientation
First, you must determine if you are on a worktree for a repository OR if you are on a regular branch on a repository OR if you are on the default branch for the repository
Second, you must determine if the branch you are on has changes on upstream / origin (as configured) that you do not have on your local branch
Third, you should determine if there are existing merge conflicts on your branch already by running git status.
Fourth, you should determine if the user has both an origin and an upstream configured.
Important: if the user is working across multiple repositories, you should ask them which repository(ies) they would like help merging in.
Step 2: Action
Depending on the results of your orientation you should take one of the following actions:
- If the user has unstaged changes which do not include merge conflicts or an ongoing merge: offer to either stash and merge, or to commit before merging, Then proceed with the following once the user answers:
- If there are existing merge conflicts on your current branch: proceed to "Conflict Resolution Procedure" and follow those instructions.
- If you are on a worktree or branch which is not for the default branch, and there are no merge conflicts:
- if the user has both upstream and origin configured: fetch the defualt branch from the upstream and then merge it into the current branch. Proceed to the "conflict resolution procedure" steps.
- if the user has only origin configured: fetch the default branch from the origin and merge it into the current branch. Proceed to the "Conflict resolution procedure" steps.
- If you are on the default branch and there are no merge conflicts and no changes on origin/upstream: Indicate this to the user and ask what they would like you to do.
Conflict Resolution Procedure
- Read the
ticket.mdand structure outline artifacts. These should contain sufficient context about the user's task and what they are working on. You may later read the plan file if you determine that more information is needed. - Use sub-agents to analyze the git state on the current branch and on the branch the conflicts come from to understand what was done and why they diverge.
- Use sub-agents to read the entire file for each conflict, as well as key relevant code and modules to understand the scope and nature of each conflict
- For each conflict (not necessarily each individual confict, e.g. group two related conflicts in the same file together e.g. for a function change and an import change for it), provide an analysis to the user of:
a. What is on HEAD
b. What is on the branch that the conflict is coming from (probably
mainor the other default branch) c. Based on the scope of the current task, recent commits to it and to the branch where the source of the conflict is coming from, how you recommend resolving it (keep HEAD, keep other branch, merge them), and why Keep your analysis concise, offer to provide more detail to the user if they ask. - Ask the user how they would like to proceed for each one.
- Work back and forth with the user to resolve all conflicts. Only make changes that the user explicitly asks for - e.g. do not resolve a conflict until the user confirms the approach or instructs you to make the change.
- Once all merge conflicts are resolved, ask the user if they would like you to commit and push. If they confirm, you should write a conventional commit-style message indicating the branch merged in (from what commit hash), and a full body that indicates what each of the conflicts resolved was and how it was resolved and why.
IMPORTANT: Update your todo list to include items 1-7. You MUST stop and ask the user how they would like to proceed after presenting the analysis from step 4. You MUST work back and forth with the user until all conflicts have been resolved before proceeding to stop 7. The user may only give you instructions / guidance on some of the changes at a time - you should use the todo tool to track which ones have been completed and which ones still need resolution in your todo list.
常见问题
它会替我提交更改吗?
它会先询问。如果你有未保存的更改,它会提议先暂存或提交,再进行合并。
它能跨多个仓库工作吗?
如果你跨多个仓库工作,它会询问你希望帮忙合并哪些仓库。
它会先检查我的远程仓库吗?
会。它会检查已配置哪些远程仓库,以及远程分支是否有你还没有的更改。
详情
热度
- GitHub 星标
- 13k
- 排名
- #11387
- 许可证
- Apache-2.0
- 更新时间
- 2026/10/31
评论
- …
同一仓库的更多技能
asd-ste100
13k教你的智能体把难懂的英文改写成短句、每句只有一个意思,方便人和其他软件阅读。
better-github-skill
13k帮你的智能体查看拉取请求的状态、阅读其审查评论,并借助现成的 GitHub 脚本找出 CI 构建失败的原因。
calldiff
13k帮你的智能体比较代码库中两个 git 版本之间的函数调用链,让代码审查能看出行为发生了什么变化。
chrome-devtools-cli
13k帮你的智能体通过终端控制 Chrome,打开页面、点击、填写表单,并截取页面快照,用于浏览器自动化和测试。