Git 合并冲突解决
git.merge_conflicts
解决 git 合并(merge)、变基(rebase)或拣选(cherry-pick)冲突,并完成该操作
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-02
- Stars
- ★ 155
- Forks
- 170
01 前言 Front Matter
- model
- haiku
- description
- Resolve git merge, rebase, or cherry-pick conflicts and finalize the operation
03 SKILL.md 正文
Goal
- Given a repo with unresolved Git conflicts, understand why each conflict happened, resolve it, verify the result, and finalize the in-progress operation
Workflow
Identify the Operation In Progress
- Determine whether the repo is in the middle of a
merge,rebase, orcherry-pick, since finalizing the resolution differs by operation> ls -a .git | grep -E "MERGE_HEAD|rebase-merge|rebase-apply|CHERRY_PICK_HEAD" - Note
<SOURCE>, the branch/commit being merged, rebased, or cherry-picked in, and<TARGET>, the branch that already contains history (e.g.,mainduring a merge, or the branch being rebased onto)
Find the Files with Conflicts
- Find the files with conflicts running
> git diff --name-only --diff-filter=U
Understand the Context
- Understand the context, e.g., by looking at the PR description, if present
> gh pr view- If there is no open PR,
gh pr viewfails: skip it and rely on commit history instead
- If there is no open PR,
- Look at the previous commits on
<SOURCE>and<TARGET>that lead to the conflict, to understand the intent behind each side> git log <TARGET>..<SOURCE> > git log <SOURCE>..<TARGET>
Propose Fixes
-
For each file with conflicts:
- List every conflict hunk in the file (a file can have more than one
<<<<<<</=======/>>>>>>>block) - For each hunk (or set of similar hunks), explain why the conflict happened and propose what needs to be done
- List every conflict hunk in the file (a file can have more than one
-
Example
1. tutorials/GitHub_Stats/Master_GitHub_analysis.py - Issue: Jupytext version conflict. - Resolution: Use <TARGET>, it's the newer version. 2. tutorials/GitHub_Stats/docker_jupyter.sh - Issue: <SOURCE> adds -e GITHUB_ACCESS_TOKEN to Docker env; <TARGET> removes it. - Resolution: Use <TARGET> (remove the line) -
If unsure what to do, prefer the changes from
<SOURCE>over<TARGET><TARGET>'s history is already saved, while discarding<SOURCE>'s changes could lose them permanently
Ask User and Apply the Changes
- Ask the user which resolution to apply for each ambiguous case
- Edit each conflicted file to remove the conflict markers and apply the chosen resolution
- Confirm no conflict markers remain in any resolved file
> grep -rn '^<<<<<<<\|^=======\|^>>>>>>>' <RESOLVED_FILES> - Stage each resolved file
> git add <FILE>
Finalize the Operation
- You MUST ask for user permission before finalizing, per the repo rule of never committing without permission
- Once approved, finalize based on the operation identified above:
merge:git commitrebase:git rebase --continuecherry-pick:git cherry-pick --continue
- Do not skip hooks (e.g.,
--no-verify) or force anything unless the user explicitly asks for it
Verification
- [ ] Run the related unit tests to make sure everything is fine
- [ ] Confirm there are no conflict markers
<<<<<<</=======/>>>>>>> - [ ] Confirm the operation finished cleanly
> git status
Ask for Help If Unsure How to Do
- If the task is not perfectly clear, you MUST not perform it, but ask for
clarifications
- When the task is complex, create a plan.md with 5 bullet points explaining what the plan is
04 同仓库更多 Skills
Docker 文件同步与模板对齐
tutorial_in_60_mins.propagate_docker_changes
同步教程和课程项目的 Docker 文件,使其与 project_template 保持一致。
Markdown 合并至 Jupyter Notebook
tutorial_in_60_mins.merge_markdown
将 Markdown 文件的内容合并到 Jupyter Notebook 中。
60 分钟教程格式规范化
tutorial_in_60_mins.format
格式化目录,使其遵循「Learn X in 60 Minutes」(60 分钟学会 X)教程约定。
60 分钟教程目录创建
tutorial_in_60_mins.create
按照「Learn X in 60 Minutes」(60 分钟学会 X)约定创建教程目录。
todo.reorg_in_progress
Reorganize ai_task_queue.md so in-progress tasks, not-started tasks, and mislabeled topic headers sit under the right H1 stage
todo.reorg_headers
Reorganize ai_task_queue.md .md so every H2 topic matches ALL TOPICS and every H3 task sits under the right topic, keeping its H1 stage