Resolve Merge Conflicts

作者 warpdotdev2a03b403b4f8無授權條款收錄於 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 從公開儲存庫中收錄這些內容。

檢舉或申請下架