resolve-git-conflicts
Acerca de
Esta habilidad de Claude ayuda a los desarrolladores a resolver conflictos de Git en operaciones de fusión, reorganización, selección de commits y almacenamiento temporal. Te guía a través de la lectura de marcadores de conflicto, la elección de estrategias de resolución y la continuación o cancelación segura de operaciones. Úsala cuando Git reporte conflictos o cuando necesites recuperarte de intentos fallidos de fusión o reorganización.
Instalación rápida
Claude Code
Recomendadonpx skills add pjt222/agent-almanac -a claude-code/plugin add https://github.com/pjt222/agent-almanacgit clone https://github.com/pjt222/agent-almanac.git ~/.claude/skills/resolve-git-conflictsCopia y pega este comando en Claude Code para instalar esta habilidad
Documentación
解 Git 衝突
識、解並自合併與 rebase 衝突中復原。
適用時機
git merge或git rebase報衝突git cherry-pick無法乾淨應用git pull致衝突變更git stash pop與當前工作樹衝突
輸入
- 必要:含活動衝突之倉庫
- 選擇性:偏好之解策(ours、theirs、手動)
- 選擇性:何變更應優先之上下文
步驟
步驟一:識衝突源
定何操作致衝突:
# Check current status
git status
# Look for indicators:
# "You have unmerged paths" — merge conflict
# "rebase in progress" — rebase conflict
# "cherry-pick in progress" — cherry-pick conflict
狀態輸出告知何文件有衝突且何操作進行中。
預期: git status 顯示「Unmerged paths」之下之文件並指明活動操作。
失敗時: 若 git status 顯潔淨樹但本期望衝突,操作恐已完成或中止。檢 git log 之近期活動。
步驟二:讀衝突標記
開每衝突文件並定衝突標記:
<<<<<<< HEAD
// Your current branch's version
const result = calculateWeightedMean(data, weights);
=======
// Incoming branch's version
const result = computeWeightedAverage(data, weights);
>>>>>>> feature/rename-functions
<<<<<<< HEAD至=======:當前分支(或正 rebase 至之分支)=======至>>>>>>>:來入變更(正合併之分支或正應用之提交)
預期: 每衝突文件含一個或多個含 <<<<<<<、=======、>>>>>>> 標記之塊。
失敗時: 若無標記但文件顯為衝突,衝突恐為二進位文件或刪vs改之衝突。檢 git diff --name-only --diff-filter=U 以見完整清單。
步驟三:擇解策
手動合併(最常):編文件以邏輯合併兩變,繼移所有衝突標記。
接受 ours(保當前分支版本):
# For a single file
git checkout --ours path/to/file.R
git add path/to/file.R
# For all conflicts
git checkout --ours .
git add -A
接受 theirs(保來入分支版本):
# For a single file
git checkout --theirs path/to/file.R
git add path/to/file.R
# For all conflicts
git checkout --theirs .
git add -A
預期: 解後文件含正確合併內容,無餘衝突標記。
失敗時: 若擇錯側,自合併基重讀衝突版。合併中 git checkout -m path/to/file 重建衝突標記以再試。
步驟四:標文件為已解
編每衝突文件後:
# Stage the resolved file
git add path/to/resolved-file.R
# Check remaining conflicts
git status
對「Unmerged paths」之每文件重複之。
預期: 所有文件自「Unmerged paths」移至「Changes to be committed」。任何文件中無餘衝突標記。
失敗時: 若 git add 失敗或標記留存,重開文件並確 <<<<<<<、=======、>>>>>>> 行皆移除。
步驟五:續操作
所有衝突已解後:
合併:
git commit
# Git auto-populates the merge commit message
rebase:
git rebase --continue
# May encounter more conflicts on subsequent commits — repeat steps 2-4
cherry-pick:
git cherry-pick --continue
stash pop:
# Stash pop conflicts don't need a continue — just commit or reset
git add .
git commit -m "Apply stashed changes with conflict resolution"
預期: 操作完成。git status 顯潔淨工作樹(或 rebase 中移至下一提交)。
失敗時: 若續命令失敗,檢 git status 之餘未解文件。所有衝突須解後方續。
步驟六:需則中止
若解過繁或擇錯法,安全中止:
# Abort merge
git merge --abort
# Abort rebase
git rebase --abort
# Abort cherry-pick
git cherry-pick --abort
預期: 倉庫返至操作前態。無資料喪失。
失敗時: 若中止失敗(罕),檢 git reflog 以尋操作前之提交並 git reset --hard <commit> 復之。慎用——此棄未提交之變更。
步驟七:驗解
操作完成後:
# Verify clean working tree
git status
# Check that the merge/rebase result is correct
git log --oneline -5
git diff HEAD~1
# Run tests to confirm nothing is broken
# (language-specific: devtools::test(), npm test, cargo test, etc.)
預期: 潔淨工作樹、正確之合併歷史、測試通過。
失敗時: 若解後測試失敗,合併雖語法衝突已解,仍恐引邏輯錯。詳檢 diff 並修。
驗證
- 任何文件中無餘衝突標記(
<<<<<<<、=======、>>>>>>>) -
git status顯潔淨工作樹 -
git log中合併/rebase 歷史正確 - 衝突解後測試通過
- 無意外變更被引
常見陷阱
- 盲接一側:
--ours或--theirs全棄他側。唯確一版完正時方用 - 代碼留衝突標記:編後務搜整個文件之餘標記。部分解破壞代碼
- rebase 中 amend:互動式 rebase 中,除非 rebase 步具體要求,勿
--amend。改用git rebase --continue - 中止失工作:
git rebase --abort與git merge --abort棄所有解工作。唯欲重始時方中止 - 解後不測:語法潔淨之合併仍恐邏輯誤。務跑測試
- rebase 後強推:rebase 共享分支後,強推前與協作者協調,因其改寫歷史
相關技能
commit-changes— 衝突解後之提交manage-git-branches— 致衝突之分支工作流configure-git-repository— 倉庫設置與合併策略
Repositorio GitHub
Frequently asked questions
What is the resolve-git-conflicts skill?
resolve-git-conflicts is a Claude Skill by pjt222. Skills package instructions and resources that Claude loads on demand, so Claude can perform resolve-git-conflicts-related tasks without extra prompting.
How do I install resolve-git-conflicts?
Use the install commands on this page: add resolve-git-conflicts to Claude Code as a plugin, or clone its repository into your skills directory, then restart Claude so it picks up the skill.
What category does resolve-git-conflicts belong to?
resolve-git-conflicts is in the Design category, tagged ai, api and design.
Is resolve-git-conflicts free to use?
Yes. resolve-git-conflicts is listed on AIMCP and free to install. It runs inside Claude, so no separate service account is required to use the skill itself.
Habilidades relacionadas
Utilice la habilidad executing-plans cuando tenga un plan de implementación completo para ejecutar en lotes controlados con puntos de revisión. Esta habilidad carga y revisa críticamente el plan, luego ejecuta tareas en pequeños lotes (por defecto 3 tareas) mientras reporta el progreso entre cada lote para la revisión del arquitecto. Esto asegura una implementación sistemática con puntos de control de calidad integrados.
Esta habilidad despacha un subagente revisor de código para analizar los cambios en el código frente a los requisitos antes de proceder. Debe usarse después de completar tareas, implementar funciones principales o antes de fusionar con la rama principal. La revisión ayuda a detectar problemas de forma temprana al comparar la implementación actual con el plan original.
Esta habilidad proporciona una guía integral para que los desarrolladores conecten servidores MCP a Claude Code mediante transportes HTTP, stdio o SSE. Cubre la instalación, configuración, autenticación y seguridad para integrar servicios externos como GitHub, Notion y APIs personalizadas. Úsala al configurar integraciones MCP, al configurar herramientas externas o al trabajar con el Protocolo de Contexto del Modelo de Claude.
Esta habilidad ayuda a los desarrolladores a elegir entre las interfaces web y CLI de Claude Code mediante el análisis de tareas, y luego permite la teletransportación fluida de sesiones entre estos entornos. Optimiza el flujo de trabajo gestionando el estado y el contexto de la sesión al cambiar entre web, CLI o móvil. Úsala para proyectos complejos que requieren diferentes herramientas en varias etapas.
