resolve-merge-conflicts
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseResolve 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
工作流程
- Start with a summary.
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.pyUse the summary to identify which files are unresolved, which index stages exist, and how many text hunks each file contains.
- Drill into one file.
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/filePrefer this over reading the whole file. The script prints only nearby context, the / / sections for each hunk, and a compact unified diff between and .
oursbasetheirsourstheirs- Resolve the file.
- Take one side wholesale with or
git checkout --ours -- path/to/filewhen appropriate.git checkout --theirs -- path/to/file - 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.
- Re-check unresolved files.
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py
git diff --name-only --diff-filter=U- 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.
- 先查看汇总信息。
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py通过汇总信息识别哪些文件未解决、存在哪些索引阶段,以及每个文件包含多少文本代码块。
- 深入查看单个文件。
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/file优先使用此方式而非读取完整文件。该脚本仅打印冲突附近的上下文、每个代码块的//部分,以及与之间的精简统一差异。
oursbasetheirsourstheirs- 解决文件冲突。
- 在合适的情况下,使用或
git checkout --ours -- path/to/file直接采用某一方的内容。git checkout --theirs -- path/to/file - 否则直接编辑文件并移除冲突标记。
- 仅当精简输出不足以确定正确合并方式时,才读取更多文件内容。
- 重新检查未解决的文件。
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py
git diff --name-only --diff-filter=U- 验证冲突解决结果。
- 确保没有剩余未合并路径。
- 确保已解决的文件中不存在、
<<<<<<<或=======标记。>>>>>>> - 针对修改区域运行定向测试、构建或代码检查。
- 暂存已解决的文件。
Commands
命令
Summary only
仅查看汇总信息
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.pybash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.pyDetailed view for one file
查看单个文件的详细信息
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/filebash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/fileDetailed view for all conflicted files
查看所有冲突文件的详细信息
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --allbash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --allJSON output
JSON格式输出
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/file --jsonbash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py --file path/to/file --jsonTune output size
调整输出内容长度
bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py \
--file path/to/file \
--context 3 \
--max-lines 60bash
python3 .agents/skills/resolve-merge-conflicts/scripts/extract_conflict_context.py \
--file path/to/file \
--context 3 \
--max-lines 60Notes
注意事项
- 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.
- 在直接打开冲突文件前先使用该脚本。
- 逐个解决文件冲突,以保持上下文简洁。
- 可能遇到基于标记的文本冲突和仅索引冲突(如添加/添加或修改/删除)。该脚本会汇总这两种冲突,当工作区文件无冲突标记时,会回退到索引阶段预览。