Resolve Merge Conflicts

作者 warpdotdev2a03b403b4f8无许可证609 个星标收录于 2026年10月8日更新于 2026年10月8日仓库昨天更新

Resolve Git merge conflicts by extracting only unresolved paths, conflict hunks, and compact diffs instead of loading whole files into context. Use when a merge, rebase, cherry-pick, or stash pop stops on conflicts, when `git status` shows unmerged paths, or when files contain conflict markers.

AI 生成的概览

通过仅提取未解决路径、冲突片段和紧凑差异来解析 Git 合并冲突,而非加载整个文件。

功能
该技能指导智能体使用随附的 Python 脚本解析 Git 合并冲突,该脚本用于提取冲突上下文。脚本会输出未解决路径、索引阶段和片段数量的摘要,并可针对单个文件或所有文件展开查看附近上下文、ours/base/theirs 各部分以及紧凑的统一差异。它还支持 JSON 输出以及可调整的上下文和行数限制,并在工作区文件没有冲突标记时回退到索引阶段预览。工作流程涵盖解析文件、重新检查未合并路径以及验证不再残留冲突标记。
适用场景
适用于合并、变基、拣选或暂存弹出因冲突而中止时,git status 显示未合并路径时,或文件中包含冲突标记时。其目的是通过一次检查一个冲突文件来保持上下文精简,而不是打开整个文件。
运行要求
需要 Git 和 Python 3 运行时来运行随附脚本 scripts/extract_conflict_context.py。该脚本通过 python3 调用,支持 --file、--all、--json、--context 和 --max-lines 等参数。

Resolve Merge Conflicts

Overview

Resolve conflicts without opening full files unless the compact view is insufficient. Start with a summary, then inspect one conflicted file at a time.

Workflow

  1. Start with a summary.
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py

Use the summary to identify which files are unresolved, which index stages exist, and how many text hunks each file contains.

  1. Drill into one file.
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/file

Prefer this over reading the whole file. The script prints only nearby context, the ours / base / theirs sections for each hunk, and a compact unified diff between ours and theirs.

  1. Resolve the file.
  • Take one side wholesale with git checkout --ours -- path/to/file or git checkout --theirs -- path/to/file when appropriate.
  • Otherwise edit the file directly and remove the conflict markers.
  • Read more of the file only if the compact output is not enough to decide the correct merge.
  1. Re-check unresolved files.
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.pygit diff --name-only --diff-filter=U
  1. Validate the resolution.
  • Ensure no unmerged paths remain.
  • Ensure no <<<<<<<, =======, or >>>>>>> markers remain in the resolved files.
  • Run targeted tests, builds, or linters for the touched area.
  • Stage the resolved files.

Commands

Summary only

bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py

Detailed view for one file

bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/file

Detailed view for all conflicted files

bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --all

JSON output

bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/file --json

Tune output size

bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py \  --file path/to/file \  --context 3 \  --max-lines 60

Notes

  • Use the script before opening conflicted files directly.
  • Resolve one file at a time to keep context small.
  • Expect marker-based text conflicts and index-only conflicts such as add/add or modify/delete. The script summarizes both, and it falls back to index-stage previews when the worktree file has no conflict markers.

来源与署名

来源:warpdotdev/common-skills位于.agents/skills/resolve-merge-conflicts提交2a03b40

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架