Git Resolve Conflicts
When to Use
Use this skill when:
- Git reports unmerged paths, conflict markers, or an in-progress merge, rebase, cherry-pick, revert, stash pop, or pull conflict.
- The user asks to resolve merge conflicts, rebase conflicts, cherry-pick conflicts, branch integration conflicts, or conflict markers.
- A commit, PR, pull, merge, rebase, cherry-pick, or release workflow is blocked by conflicts.
- The work requires choosing between
ours, theirs, base, regenerated output, or a combined resolution.
Do Not Use
Do not use this skill when:
- There is no active conflict and the user only wants a commit, PR, history inspection, or branch comparison. Use the relevant git skill instead.
- The user only wants a conceptual explanation of Git conflict terminology.
- A completed merge introduced a bug or failing test but Git has no active conflict state. Use
structured-problem-resolution.
- The requested action is to abort, reset, force-push, drop commits, rewrite published history, or discard work. Those are separate high-impact actions requiring explicit user instruction.
- A project-specific workflow says this conflict must be surfaced, aborted, or re-dispatched instead of hand-resolved, such as stash-pop recovery, generated registry refreshes, or isolated subagent branch integration.
- The conflict arose while merging isolated delegated work in an orchestrated workflow and the governing workflow owns abort, serial re-dispatch, or rerun policy. Report the Git state and return control to that workflow unless the user explicitly authorizes manual resolution with the named loss-of-intent risk.
- Conflict resolution depends on a product, legal, release, or responsibility decision that cannot be inferred from repository evidence.
Iron Law
Resolve intent, not markers. Every conflict resolution must be grounded in the purpose of both sides, preserve compatible intent, avoid blind side selection, and be verified before the operation is continued or reported complete.
Core Concept
A conflict is competing history, not a text-editing inconvenience. Conflict markers show where Git stopped; they do not explain why either side changed. The job is to recover intent, choose the smallest correct integration, verify behavior, and leave the repository in a clear Git state.
Operating Process
Run these steps in order. Do not skip from conflict markers directly to editing.
1. Identify The Operation And Conflict State
Start from Git state, not memory.
Run:
git rev-parse --show-toplevel
git status --short --branch
git status
git diff --name-only --diff-filter=U
git ls-files -u
Work from the resolved repository root, or use explicit repo-relative paths for every read, edit, restore, and staging command. Record the active toplevel and branch before mutating files.
If Git exposes an AUTO_MERGE tree for the current merge strategy, inspect it as an aid, not as a source of truth:
git rev-parse --verify -q AUTO_MERGE
git diff AUTO_MERGE
Identify:
- current branch and whether the repository is merging, rebasing, cherry-picking, reverting, applying a stash, or resolving a pull-created merge;
- active repository root and checkout/worktree where the conflict state exists;
- all unmerged paths;
- whether conflicts are content, add/add, delete/modify, rename/rename, rename/delete, mode, binary, submodule, generated-file, or lockfile conflicts;
- any unrelated modified or untracked files that predate the conflict.
Worktree guard:
- Resolve conflicts only in the checkout/worktree where
git status reports the active operation and unmerged paths.
- If an upstream workflow explicitly required isolated work and the current checkout is not the intended isolated workspace, stop before editing and ask for direction.
- Do not create or switch worktrees to escape a conflict. Conflict state is checkout-local, and moving elsewhere can leave the actual unmerged index unresolved.
Operation matrix:
| Operation |
State signal |
Continuation after verified resolution |
Special rule |
| Merge or pull-created merge |
git status says merging, or .git/MERGE_HEAD exists |
git merge --continue |
Merge abort may not restore a dirty pre-merge state; do not abort without explicit user instruction and loss analysis. |
| Rebase or pull rebase |
git status says rebasing, or .git/rebase-merge / .git/rebase-apply exists |
git rebase --continue |
ours is the branch being rebased onto; theirs is the commit being replayed. |
| Cherry-pick |
git status says cherry-picking, or .git/CHERRY_PICK_HEAD exists |
git cherry-pick --continue |
Preserve the picked commit's intent unless current branch contracts make it obsolete. |
| Revert |
git status says reverting, or .git/REVERT_HEAD exists |
git revert --continue |
Reverting a merge commit requires explicit mainline semantics; do not infer -m <parent>. |
| Stash pop/apply |
Stash conflict output and unmerged paths, with no continue command |
No Git continue command |
Surface stash ref/state when intent is unclear; do not auto-resolve hidden local work. |
Completion criterion: the operation type, repository root, active checkout/worktree, conflict files, conflict categories, and non-conflict working-tree changes are known.
Failure output: Blocked: conflict state is unclear or unsafe to inspect: <specific missing state>.
2. Recover Both Sides' Intent
For each conflicted file, find why each side changed.
Use the lightest evidence that explains intent:
- Git state, index stages, base/ours/theirs blobs, commit diffs/messages, and repository history;
- surrounding source and call sites;
- commit messages and diffs touching the file;
- specs, ADRs, plans, issues, PR notes, migration notes, or generated-file sources;
- tests or snapshots that define expected behavior;
- schema, API, or contract files that constrain valid output.
Evidence classes:
Observed Git evidence: current operation, index stages, base/ours/theirs blobs, commits, diffs, paths, conflict class, and generated-file source inputs.
Inferred intent: the reason each side changed, derived from observed evidence and nearby source.
Advisory context: specs, ADRs, plans, issues, PR notes, dogfood reports, optimization logs, prior learnings, Slack/user notes, or documentation that explain possible intent but still require repository verification before side selection or continuation.
Useful commands:
git log --oneline --merge -- <path>
git log --merge -p -- <path>
git log --oneline -- <path>
git diff --base -- <path>
git diff --ours -- <path>
git diff --theirs -- <path>
git show :1:<path>
git show :2:<path>
git show :3:<path>
Rules:
- Do not treat
ours and theirs as intuitive labels until the operation is known. During rebase and pull --rebase, ours is the branch being rebased onto and theirs is the commit being replayed; this often feels reversed from the feature-branch perspective.
- Use index stages deliberately:
:1: is base, :2: is ours, and :3: is theirs. If a stage is missing, explain the conflict class before choosing a resolution.
- Do not choose a side because it is shorter, newer, less noisy, or makes tests compile.
- Do not trust conflict-marker text alone; read enough context to know what each side was trying to preserve.
- If a side came from a generated file, recover the source input before resolving the generated output.
- If prior learnings, session history, or project vocabulary exist for a historically fragile conflict class, use them only as advisory context for evidence gathering and verification selection. Current Git state, index stages, source, tests, specs, and explicit user instruction remain authoritative.
- If advisory context conflicts with current repository evidence, follow current repository evidence and flag the advisory source as stale or inapplicable.
For high-risk or multi-file conflicts, write a compact per-path basis before editing:
- observed Git evidence;
- inferred intent for each side;
- advisory context used, if any;
- candidate resolutions considered;
- unsupported candidates rejected with a reason;
- chosen strategy or blocker;
- verification required for that conflict surface.
Completion criterion: every conflict has a written resolution basis: both intents are known, one side is intentionally obsolete, or the missing intent is named as a blocker.
Failure output: Blocked: cannot resolve conflict without intent evidence for <path>: <missing evidence>.
3. Choose The Resolution Strategy
Choose the smallest resolution that satisfies the known intents.
Before editing broad conflict sets, group paths by conflict surface:
- API/schema/contract;
- implementation and call sites;
- tests, fixtures, snapshots, and generated clients;
- migrations, data shape, lockfiles, package manifests, and build tooling;
- docs, instructions, plans, ADRs, and release notes;
- UI routes, components, styles, screenshots, and browser-visible behavior;
- binary, submodule, image, or opaque artifacts;
- local-only, sensitive, provider, credential-adjacent, cache, temp, or runtime artifacts;
- unrelated dirty work.
Resolution rules:
- Preserve both sides when they are compatible.
- If intents conflict, prefer the side matching the merge/rebase/cherry-pick goal, accepted spec/ADR/plan, current contract, or explicit user instruction.
- If one side deleted a file and the other modified it, verify whether the deleted responsibility moved elsewhere before keeping the modification. A delete/modify conflict is not resolved until the surviving component is known or the missing responsibility decision is named as a blocker.
- If a file was renamed or moved, apply the surviving behavioral change to the surviving path instead of resurrecting duplicate structure.
- If a generated file or lockfile conflicts, resolve source inputs first, regenerate with the project's normal package manager or generator, review the regenerated diff, and stage it only when it matches the intended dependency/artifact state.
- If a binary, submodule, image, or opaque artifact conflicts, choose or regenerate it from explicit evidence; otherwise stop for user decision.
- If local-only, credential-adjacent, provider, cache, temp, runtime, or generated report artifacts conflict, treat them as sensitive or environment-specific unless repository evidence proves they are intentional tracked project artifacts. Do not stage incidental local config, auth state, logs, screenshots, sockets,
.env files, caches, generated drafts, copied databases, result markers, or scratch files merely because they appeared during conflict resolution.
- If resolving an optimization, dogfood, browser-polish, product-pulse, promotion, or other workflow artifact, use that workflow's reports only to recover intent and choose verification. Do not run that workflow, change its decisions, or treat its green output as resolution authority.
- If resolving would alter measurement harnesses, evaluation data, privacy-sensitive report output, security checks, authorization, validation, escaping, sanitization, data-loss prevention, or accessibility safeguards, stop unless repository evidence proves the change intentionally replaced the safeguard.
- Do not confuse merge strategies with hunk resolution.
-X ours / -X theirs biases conflicting hunks while still merging non-conflicting changes; -s ours records a merge while ignoring the other tree. Neither is a safe shortcut for an active conflict unless the exact blast radius is intentional and explicitly authorized.
- Do not invent new behavior just to make the conflict disappear.
Completion criterion: each file has a chosen resolution strategy and the strategy names the evidence it preserves.
Failure output: Blocked: resolution would require inventing behavior or discarding unverified intent in <path>.
4. Edit And Stage Deliberately
Apply the chosen resolution manually or with a merge tool. Use side-selection commands only after Step 2 and Step 3 justify that exact path or hunk.
Rules:
- Remove all conflict markers from resolved files.
- Preserve formatting and local style around the resolved code.
- Keep unrelated user edits out of the resolution.
- Stage only paths that are actually resolved.
- Do not use global shortcuts that accept one side across the repository.
- Do not turn conflict resolution into cleanup, simplification, or refactoring. Remove only conflict-introduced artifacts such as duplicate branches, stale imports, dead code, or narrating comments when the removal is limited to resolved hunks and behavior-preserving.
- Prefer path-level restore only when the earlier evidence justifies it for that path:
git restore --ours -- <path>
git restore --theirs -- <path>
git restore --merge --conflict=diff3 -- <path> or git restore --merge --conflict=zdiff3 -- <path> when richer conflict context is needed.
- Do not run abort/reset/clean/checkout commands that discard work unless the user explicitly asked for that exact destructive action.
After resolving a path, stage it explicitly:
git add -- <path>
Completion criterion: resolved paths are edited intentionally, staged explicitly, and no unresolved path is staged by accident.
Failure output: Blocked: resolved edit or staging scope is unsafe: <specific path/state>.
5. Verify The Resolution
Git-level cleanup is necessary but not sufficient.
Run:
git diff --check
git diff --name-only --diff-filter=U
Then inspect the resolved diff:
git diff
git diff --staged
Run project checks that match the conflict surface:
- formatting/lint checks when syntax, imports, or generated files changed;
- typecheck/build when code, package metadata, generated clients, schemas, or config changed;
- focused tests for affected behavior;
- broader tests when conflict spans shared contracts, migrations, APIs, core domain logic, or build tooling;
- regeneration checks for lockfiles, generated clients, snapshots, docs output, or compiled artifacts;
- affected UI routes, user journeys, or focused browser/E2E checks that the owning workflow should run or that existing evidence already covers when conflicts touch visible routes, components, layouts, styles, or client behavior;
- source-window, provenance, timestamp, missing-data, and privacy checks when conflicts touch generated reports, analytics output, logs, traces, screenshots, or saved operational artifacts;
- configured measurement and hard-gate checks that the owning optimization workflow should run or already ran when conflicts occur inside an approved optimization workflow and the spec/logs define those checks.
Rules:
git diff --name-only --diff-filter=U must produce no unresolved paths before the operation continues.
- Passing unrelated tests is not evidence for the conflict resolution.
- Do not start browser/dev-server/dogfood/optimization workflows from this skill. When those checks are needed, identify the affected surface, cite existing evidence if available, and report the required follow-up through the responsible skill or residual risk.
- Review
git diff --staged as if reviewing someone else's conflict resolution before continuation. Check each selected outcome against its stated basis, especially for rebase side reversal, delete/modify responsibility, generated artifacts, lockfiles, behavior-bearing tests, and workflow-owned artifacts.
- If a check fails, classify it before continuing: conflict-caused, demonstrably pre-existing, unrelated to the resolved surface, or unknown. Conflict-caused and unknown failures block continuation unless the user explicitly accepts the named risk.
- If verification cannot run, record the exact blocked check and residual risk before continuing.
Completion criterion: Git reports no unresolved paths, conflict markers/check failures are gone, and behavior/build verification matches the risk of the conflict.
Failure output: Blocked: conflict resolution is not verified: <missing or failing check>.
6. Continue Or Finish The Git Operation
Continue only after Step 5 passes or the user explicitly accepts the named verification risk.
Use the operation-specific continuation:
git merge --continue
git rebase --continue
git cherry-pick --continue
git revert --continue
Rules:
- Use only the continuation command that matches the active operation.
- For stash conflicts, there is no
stash --continue; after resolving, report the clean state and whether the user still needs a commit.
- If continuation opens the next conflict during a rebase/cherry-pick/revert sequence, return to Step 1 for the new conflict.
- If a continuation command fails, do not retry blindly. Read the full failure output and current
git status, classify whether the failure is unresolved paths, editor/commit-message issue, hook/check failure, empty commit, another conflict, or stale state, then return to the matching step.
- Do not push after resolving conflicts unless the user separately asks to push or create/update a PR.
- Do not add attribution, assistant signatures, or generated-by footers to merge commit messages.
Completion criterion: the merge/rebase/cherry-pick/revert/stash conflict is complete, or the next conflict/blocker is identified with exact state.
Failure output: Blocked: cannot continue the Git operation safely: <specific operation/state/check>.
Output Contract
Report:
- active operation and branch;
- conflicted files and conflict categories;
- repository root and active checkout/worktree used;
- observed Git evidence, inferred intent, and advisory context used for each resolved area;
- resolution choices and any side-selection commands used;
- rejected candidate resolutions for high-risk conflicts;
- verification commands and results;
- final Git state: completed, next conflict, or blocked;
- residual risks, skipped checks, or user decisions still required.
Stop Conditions
Stop instead of resolving when:
- intent for either side cannot be recovered and choosing would discard behavior;
- a generated artifact cannot be regenerated and hand-editing would be unreliable;
- a binary/submodule/opaque artifact choice is not obvious from repository evidence;
- a project workflow says this class of conflict must be surfaced instead of hand-resolved, such as stash-pop conflicts carrying hidden local work or orchestrated subagent branch merges where re-dispatch is the safer preservation path;
- the conflict arose while merging isolated delegated work and the owning workflow requires abort, serial re-dispatch, or rerun instead of manual conflict editing;
- a revert conflict involves a merge commit and the mainline parent or future-merge consequence is not explicit;
- pre-existing user edits are mixed with conflict edits and cannot be separated safely;
- verification requires unavailable credentials, services, files, or tools and the risk is material;
- a product, legal, release, marketing, naming, responsibility, privacy, or user-facing announcement decision is needed to decide the resolution;
- the user asks for destructive recovery without naming the exact acceptable loss.
When blocked on a decision, ask one targeted question for the specific path or decision. Include the recovered evidence and the consequence of each plausible choice. Do not ask broad multi-issue questions or keep interrogating when the next safe action is to stop.
Rationalization Table
| Temptation |
Reality |
Required Action |
| "Just take ours." |
ours may not mean what you think, especially during rebase, and may discard valid intent. |
Identify the operation and justify side selection per path or hunk. |
| "Just take theirs." |
Newer or incoming code is not automatically correct. |
Recover both sides' intent and preserve compatible behavior. |
"Use -s ours to finish." |
-s ours ignores the other tree; it is not the same as resolving conflicting hunks. |
Use strategy options only with explicit blast-radius approval. |
| "Remove the markers until it compiles." |
Compilation can hide lost behavior, deleted contracts, or stale generated output. |
Resolve from intent, then verify behavior. |
| "The lockfile conflict is just noise." |
Lockfiles encode dependency resolution and can break installs or builds. |
Resolve manifests first and regenerate when possible. |
| "Git says all conflicts fixed, so done." |
A staged resolution can still be semantically wrong. |
Run conflict-surface checks before continuing. |
| "This merge is too hard; abort it." |
Abort/reset discards integration state and may lose work. |
Stop and ask only if aborting is the explicitly desired destructive action. |
| "The plan/report/test matrix says which side wins." |
External artifacts explain intent but do not prove index-stage semantics or current code correctness. |
Treat them as advisory context and verify against Git state, source, and checks. |
| "This was a delegated branch merge, so I can hand-resolve it." |
Manual edits can collapse independent unit intent and hide the need for serial re-dispatch. |
Return control to the owning workflow unless manual resolution is explicitly authorized. |
| "The file is local/generated, so either side is fine." |
Local, sensitive, or generated artifacts can leak data, stale state, or provider output. |
Prove tracked intent or stop; regenerate from source when possible. |
Red Flags
- Conflict resolution starts before
git status and unmerged paths are inspected.
ours or theirs is used globally across the repository.
ours / theirs is interpreted without checking whether the operation is a rebase or pull-rebase.
-X ours / -X theirs or -s ours is used to avoid understanding the conflict.
- A delete/modify conflict keeps both files without checking whether responsibility moved.
- Generated files or lockfiles are hand-edited while their source inputs remain conflicted.
- Stash-pop or orchestrated subagent merge conflicts are silently hand-resolved when the safer workflow is to surface the conflict, re-dispatch, or ask for a decision.
- Local-only, credential-adjacent, cache, temp, runtime, generated report, or provider files are staged without proving they are intentional tracked artifacts.
- Advisory artifacts such as plans, PR notes, dogfood reports, optimization logs, prior learnings, or release notes are treated as authority over current Git state.
- A browser, dogfood, optimization, or promotion workflow is resumed before the active conflict state is understood, verified, or deliberately blocked.
- Conflict markers remain in source, snapshots, docs, or generated output.
- The operation is continued with unresolved paths, skipped material checks, or unexplained verification gaps.
- A merge/rebase/cherry-pick is completed and then pushed without separate push/PR authorization.
1---2name: git-resolve-conflicts3description: Use when resolving in-progress Git merge, rebase, cherry-pick, revert, stash, or pull conflicts; unmerged paths; conflict markers; ours/theirs choices; lockfile/generated-file conflicts; or branch integration conflicts before commit or PR work.4---56# Git Resolve Conflicts78## When to Use910Use this skill when:1112- Git reports unmerged paths, conflict markers, or an in-progress merge, rebase, cherry-pick, revert, stash pop, or pull conflict.13- The user asks to resolve merge conflicts, rebase conflicts, cherry-pick conflicts, branch integration conflicts, or conflict markers.14- A commit, PR, pull, merge, rebase, cherry-pick, or release workflow is blocked by conflicts.15- The work requires choosing between `ours`, `theirs`, base, regenerated output, or a combined resolution.1617## Do Not Use1819Do not use this skill when:2021- There is no active conflict and the user only wants a commit, PR, history inspection, or branch comparison. Use the relevant git skill instead.22- The user only wants a conceptual explanation of Git conflict terminology.23- A completed merge introduced a bug or failing test but Git has no active conflict state. Use `structured-problem-resolution`.24- The requested action is to abort, reset, force-push, drop commits, rewrite published history, or discard work. Those are separate high-impact actions requiring explicit user instruction.25- A project-specific workflow says this conflict must be surfaced, aborted, or re-dispatched instead of hand-resolved, such as stash-pop recovery, generated registry refreshes, or isolated subagent branch integration.26- The conflict arose while merging isolated delegated work in an orchestrated workflow and the governing workflow owns abort, serial re-dispatch, or rerun policy. Report the Git state and return control to that workflow unless the user explicitly authorizes manual resolution with the named loss-of-intent risk.27- Conflict resolution depends on a product, legal, release, or responsibility decision that cannot be inferred from repository evidence.2829## Iron Law3031Resolve intent, not markers. Every conflict resolution must be grounded in the purpose of both sides, preserve compatible intent, avoid blind side selection, and be verified before the operation is continued or reported complete.3233## Core Concept3435A conflict is competing history, not a text-editing inconvenience. Conflict markers show where Git stopped; they do not explain why either side changed. The job is to recover intent, choose the smallest correct integration, verify behavior, and leave the repository in a clear Git state.3637## Operating Process3839Run these steps in order. Do not skip from conflict markers directly to editing.4041### 1. Identify The Operation And Conflict State4243Start from Git state, not memory.4445Run:4647```bash48git rev-parse --show-toplevel49git status --short --branch50git status51git diff --name-only --diff-filter=U52git ls-files -u53```5455Work from the resolved repository root, or use explicit repo-relative paths for every read, edit, restore, and staging command. Record the active toplevel and branch before mutating files.5657If Git exposes an `AUTO_MERGE` tree for the current merge strategy, inspect it as an aid, not as a source of truth:5859```bash60git rev-parse --verify -q AUTO_MERGE61git diff AUTO_MERGE62```6364Identify:6566- current branch and whether the repository is merging, rebasing, cherry-picking, reverting, applying a stash, or resolving a pull-created merge;67- active repository root and checkout/worktree where the conflict state exists;68- all unmerged paths;69- whether conflicts are content, add/add, delete/modify, rename/rename, rename/delete, mode, binary, submodule, generated-file, or lockfile conflicts;70- any unrelated modified or untracked files that predate the conflict.7172Worktree guard:7374- Resolve conflicts only in the checkout/worktree where `git status` reports the active operation and unmerged paths.75- If an upstream workflow explicitly required isolated work and the current checkout is not the intended isolated workspace, stop before editing and ask for direction.76- Do not create or switch worktrees to escape a conflict. Conflict state is checkout-local, and moving elsewhere can leave the actual unmerged index unresolved.7778Operation matrix:7980| Operation | State signal | Continuation after verified resolution | Special rule |81| --------------------------- | ------------------------------------------------------------------------------- | -------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |82| Merge or pull-created merge | `git status` says merging, or `.git/MERGE_HEAD` exists | `git merge --continue` | Merge abort may not restore a dirty pre-merge state; do not abort without explicit user instruction and loss analysis. |83| Rebase or pull rebase | `git status` says rebasing, or `.git/rebase-merge` / `.git/rebase-apply` exists | `git rebase --continue` | `ours` is the branch being rebased onto; `theirs` is the commit being replayed. |84| Cherry-pick | `git status` says cherry-picking, or `.git/CHERRY_PICK_HEAD` exists | `git cherry-pick --continue` | Preserve the picked commit's intent unless current branch contracts make it obsolete. |85| Revert | `git status` says reverting, or `.git/REVERT_HEAD` exists | `git revert --continue` | Reverting a merge commit requires explicit mainline semantics; do not infer `-m <parent>`. |86| Stash pop/apply | Stash conflict output and unmerged paths, with no continue command | No Git continue command | Surface stash ref/state when intent is unclear; do not auto-resolve hidden local work. |8788Completion criterion: the operation type, repository root, active checkout/worktree, conflict files, conflict categories, and non-conflict working-tree changes are known.8990Failure output: `Blocked: conflict state is unclear or unsafe to inspect: <specific missing state>.`9192### 2. Recover Both Sides' Intent9394For each conflicted file, find why each side changed.9596Use the lightest evidence that explains intent:9798- Git state, index stages, base/ours/theirs blobs, commit diffs/messages, and repository history;99- surrounding source and call sites;100- commit messages and diffs touching the file;101- specs, ADRs, plans, issues, PR notes, migration notes, or generated-file sources;102- tests or snapshots that define expected behavior;103- schema, API, or contract files that constrain valid output.104105Evidence classes:106107- `Observed Git evidence`: current operation, index stages, base/ours/theirs blobs, commits, diffs, paths, conflict class, and generated-file source inputs.108- `Inferred intent`: the reason each side changed, derived from observed evidence and nearby source.109- `Advisory context`: specs, ADRs, plans, issues, PR notes, dogfood reports, optimization logs, prior learnings, Slack/user notes, or documentation that explain possible intent but still require repository verification before side selection or continuation.110111Useful commands:112113```bash114git log --oneline --merge -- <path>115git log --merge -p -- <path>116git log --oneline -- <path>117git diff --base -- <path>118git diff --ours -- <path>119git diff --theirs -- <path>120git show :1:<path>121git show :2:<path>122git show :3:<path>123```124125Rules:126127- Do not treat `ours` and `theirs` as intuitive labels until the operation is known. During rebase and `pull --rebase`, `ours` is the branch being rebased onto and `theirs` is the commit being replayed; this often feels reversed from the feature-branch perspective.128- Use index stages deliberately: `:1:` is base, `:2:` is ours, and `:3:` is theirs. If a stage is missing, explain the conflict class before choosing a resolution.129- Do not choose a side because it is shorter, newer, less noisy, or makes tests compile.130- Do not trust conflict-marker text alone; read enough context to know what each side was trying to preserve.131- If a side came from a generated file, recover the source input before resolving the generated output.132- If prior learnings, session history, or project vocabulary exist for a historically fragile conflict class, use them only as advisory context for evidence gathering and verification selection. Current Git state, index stages, source, tests, specs, and explicit user instruction remain authoritative.133- If advisory context conflicts with current repository evidence, follow current repository evidence and flag the advisory source as stale or inapplicable.134135For high-risk or multi-file conflicts, write a compact per-path basis before editing:136137- observed Git evidence;138- inferred intent for each side;139- advisory context used, if any;140- candidate resolutions considered;141- unsupported candidates rejected with a reason;142- chosen strategy or blocker;143- verification required for that conflict surface.144145Completion criterion: every conflict has a written resolution basis: both intents are known, one side is intentionally obsolete, or the missing intent is named as a blocker.146147Failure output: `Blocked: cannot resolve conflict without intent evidence for <path>: <missing evidence>.`148149### 3. Choose The Resolution Strategy150151Choose the smallest resolution that satisfies the known intents.152153Before editing broad conflict sets, group paths by conflict surface:154155- API/schema/contract;156- implementation and call sites;157- tests, fixtures, snapshots, and generated clients;158- migrations, data shape, lockfiles, package manifests, and build tooling;159- docs, instructions, plans, ADRs, and release notes;160- UI routes, components, styles, screenshots, and browser-visible behavior;161- binary, submodule, image, or opaque artifacts;162- local-only, sensitive, provider, credential-adjacent, cache, temp, or runtime artifacts;163- unrelated dirty work.164165Resolution rules:166167- Preserve both sides when they are compatible.168- If intents conflict, prefer the side matching the merge/rebase/cherry-pick goal, accepted spec/ADR/plan, current contract, or explicit user instruction.169- If one side deleted a file and the other modified it, verify whether the deleted responsibility moved elsewhere before keeping the modification. A delete/modify conflict is not resolved until the surviving component is known or the missing responsibility decision is named as a blocker.170- If a file was renamed or moved, apply the surviving behavioral change to the surviving path instead of resurrecting duplicate structure.171- If a generated file or lockfile conflicts, resolve source inputs first, regenerate with the project's normal package manager or generator, review the regenerated diff, and stage it only when it matches the intended dependency/artifact state.172- If a binary, submodule, image, or opaque artifact conflicts, choose or regenerate it from explicit evidence; otherwise stop for user decision.173- If local-only, credential-adjacent, provider, cache, temp, runtime, or generated report artifacts conflict, treat them as sensitive or environment-specific unless repository evidence proves they are intentional tracked project artifacts. Do not stage incidental local config, auth state, logs, screenshots, sockets, `.env` files, caches, generated drafts, copied databases, result markers, or scratch files merely because they appeared during conflict resolution.174- If resolving an optimization, dogfood, browser-polish, product-pulse, promotion, or other workflow artifact, use that workflow's reports only to recover intent and choose verification. Do not run that workflow, change its decisions, or treat its green output as resolution authority.175- If resolving would alter measurement harnesses, evaluation data, privacy-sensitive report output, security checks, authorization, validation, escaping, sanitization, data-loss prevention, or accessibility safeguards, stop unless repository evidence proves the change intentionally replaced the safeguard.176- Do not confuse merge strategies with hunk resolution. `-X ours` / `-X theirs` biases conflicting hunks while still merging non-conflicting changes; `-s ours` records a merge while ignoring the other tree. Neither is a safe shortcut for an active conflict unless the exact blast radius is intentional and explicitly authorized.177- Do not invent new behavior just to make the conflict disappear.178179Completion criterion: each file has a chosen resolution strategy and the strategy names the evidence it preserves.180181Failure output: `Blocked: resolution would require inventing behavior or discarding unverified intent in <path>.`182183### 4. Edit And Stage Deliberately184185Apply the chosen resolution manually or with a merge tool. Use side-selection commands only after Step 2 and Step 3 justify that exact path or hunk.186187Rules:188189- Remove all conflict markers from resolved files.190- Preserve formatting and local style around the resolved code.191- Keep unrelated user edits out of the resolution.192- Stage only paths that are actually resolved.193- Do not use global shortcuts that accept one side across the repository.194- Do not turn conflict resolution into cleanup, simplification, or refactoring. Remove only conflict-introduced artifacts such as duplicate branches, stale imports, dead code, or narrating comments when the removal is limited to resolved hunks and behavior-preserving.195- Prefer path-level restore only when the earlier evidence justifies it for that path:196 - `git restore --ours -- <path>`197 - `git restore --theirs -- <path>`198 - `git restore --merge --conflict=diff3 -- <path>` or `git restore --merge --conflict=zdiff3 -- <path>` when richer conflict context is needed.199- Do not run abort/reset/clean/checkout commands that discard work unless the user explicitly asked for that exact destructive action.200201After resolving a path, stage it explicitly:202203```bash204git add -- <path>205```206207Completion criterion: resolved paths are edited intentionally, staged explicitly, and no unresolved path is staged by accident.208209Failure output: `Blocked: resolved edit or staging scope is unsafe: <specific path/state>.`210211### 5. Verify The Resolution212213Git-level cleanup is necessary but not sufficient.214215Run:216217```bash218git diff --check219git diff --name-only --diff-filter=U220```221222Then inspect the resolved diff:223224```bash225git diff226git diff --staged227```228229Run project checks that match the conflict surface:230231- formatting/lint checks when syntax, imports, or generated files changed;232- typecheck/build when code, package metadata, generated clients, schemas, or config changed;233- focused tests for affected behavior;234- broader tests when conflict spans shared contracts, migrations, APIs, core domain logic, or build tooling;235- regeneration checks for lockfiles, generated clients, snapshots, docs output, or compiled artifacts;236- affected UI routes, user journeys, or focused browser/E2E checks that the owning workflow should run or that existing evidence already covers when conflicts touch visible routes, components, layouts, styles, or client behavior;237- source-window, provenance, timestamp, missing-data, and privacy checks when conflicts touch generated reports, analytics output, logs, traces, screenshots, or saved operational artifacts;238- configured measurement and hard-gate checks that the owning optimization workflow should run or already ran when conflicts occur inside an approved optimization workflow and the spec/logs define those checks.239240Rules:241242- `git diff --name-only --diff-filter=U` must produce no unresolved paths before the operation continues.243- Passing unrelated tests is not evidence for the conflict resolution.244- Do not start browser/dev-server/dogfood/optimization workflows from this skill. When those checks are needed, identify the affected surface, cite existing evidence if available, and report the required follow-up through the responsible skill or residual risk.245- Review `git diff --staged` as if reviewing someone else's conflict resolution before continuation. Check each selected outcome against its stated basis, especially for rebase side reversal, delete/modify responsibility, generated artifacts, lockfiles, behavior-bearing tests, and workflow-owned artifacts.246- If a check fails, classify it before continuing: conflict-caused, demonstrably pre-existing, unrelated to the resolved surface, or unknown. Conflict-caused and unknown failures block continuation unless the user explicitly accepts the named risk.247- If verification cannot run, record the exact blocked check and residual risk before continuing.248249Completion criterion: Git reports no unresolved paths, conflict markers/check failures are gone, and behavior/build verification matches the risk of the conflict.250251Failure output: `Blocked: conflict resolution is not verified: <missing or failing check>.`252253### 6. Continue Or Finish The Git Operation254255Continue only after Step 5 passes or the user explicitly accepts the named verification risk.256257Use the operation-specific continuation:258259```bash260git merge --continue261git rebase --continue262git cherry-pick --continue263git revert --continue264```265266Rules:267268- Use only the continuation command that matches the active operation.269- For stash conflicts, there is no `stash --continue`; after resolving, report the clean state and whether the user still needs a commit.270- If continuation opens the next conflict during a rebase/cherry-pick/revert sequence, return to Step 1 for the new conflict.271- If a continuation command fails, do not retry blindly. Read the full failure output and current `git status`, classify whether the failure is unresolved paths, editor/commit-message issue, hook/check failure, empty commit, another conflict, or stale state, then return to the matching step.272- Do not push after resolving conflicts unless the user separately asks to push or create/update a PR.273- Do not add attribution, assistant signatures, or generated-by footers to merge commit messages.274275Completion criterion: the merge/rebase/cherry-pick/revert/stash conflict is complete, or the next conflict/blocker is identified with exact state.276277Failure output: `Blocked: cannot continue the Git operation safely: <specific operation/state/check>.`278279## Output Contract280281Report:282283- active operation and branch;284- conflicted files and conflict categories;285- repository root and active checkout/worktree used;286- observed Git evidence, inferred intent, and advisory context used for each resolved area;287- resolution choices and any side-selection commands used;288- rejected candidate resolutions for high-risk conflicts;289- verification commands and results;290- final Git state: completed, next conflict, or blocked;291- residual risks, skipped checks, or user decisions still required.292293## Stop Conditions294295Stop instead of resolving when:296297- intent for either side cannot be recovered and choosing would discard behavior;298- a generated artifact cannot be regenerated and hand-editing would be unreliable;299- a binary/submodule/opaque artifact choice is not obvious from repository evidence;300- a project workflow says this class of conflict must be surfaced instead of hand-resolved, such as stash-pop conflicts carrying hidden local work or orchestrated subagent branch merges where re-dispatch is the safer preservation path;301- the conflict arose while merging isolated delegated work and the owning workflow requires abort, serial re-dispatch, or rerun instead of manual conflict editing;302- a revert conflict involves a merge commit and the mainline parent or future-merge consequence is not explicit;303- pre-existing user edits are mixed with conflict edits and cannot be separated safely;304- verification requires unavailable credentials, services, files, or tools and the risk is material;305- a product, legal, release, marketing, naming, responsibility, privacy, or user-facing announcement decision is needed to decide the resolution;306- the user asks for destructive recovery without naming the exact acceptable loss.307308When blocked on a decision, ask one targeted question for the specific path or decision. Include the recovered evidence and the consequence of each plausible choice. Do not ask broad multi-issue questions or keep interrogating when the next safe action is to stop.309310## Rationalization Table311312| Temptation | Reality | Required Action |313| ---------------------------------------- | ------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- |314| "Just take ours." | `ours` may not mean what you think, especially during rebase, and may discard valid intent. | Identify the operation and justify side selection per path or hunk. |315| "Just take theirs." | Newer or incoming code is not automatically correct. | Recover both sides' intent and preserve compatible behavior. |316| "Use `-s ours` to finish." | `-s ours` ignores the other tree; it is not the same as resolving conflicting hunks. | Use strategy options only with explicit blast-radius approval. |317| "Remove the markers until it compiles." | Compilation can hide lost behavior, deleted contracts, or stale generated output. | Resolve from intent, then verify behavior. |318| "The lockfile conflict is just noise." | Lockfiles encode dependency resolution and can break installs or builds. | Resolve manifests first and regenerate when possible. |319| "Git says all conflicts fixed, so done." | A staged resolution can still be semantically wrong. | Run conflict-surface checks before continuing. |320| "This merge is too hard; abort it." | Abort/reset discards integration state and may lose work. | Stop and ask only if aborting is the explicitly desired destructive action. |321| "The plan/report/test matrix says which side wins." | External artifacts explain intent but do not prove index-stage semantics or current code correctness. | Treat them as advisory context and verify against Git state, source, and checks. |322| "This was a delegated branch merge, so I can hand-resolve it." | Manual edits can collapse independent unit intent and hide the need for serial re-dispatch. | Return control to the owning workflow unless manual resolution is explicitly authorized. |323| "The file is local/generated, so either side is fine." | Local, sensitive, or generated artifacts can leak data, stale state, or provider output. | Prove tracked intent or stop; regenerate from source when possible. |324325## Red Flags326327- Conflict resolution starts before `git status` and unmerged paths are inspected.328- `ours` or `theirs` is used globally across the repository.329- `ours` / `theirs` is interpreted without checking whether the operation is a rebase or pull-rebase.330- `-X ours` / `-X theirs` or `-s ours` is used to avoid understanding the conflict.331- A delete/modify conflict keeps both files without checking whether responsibility moved.332- Generated files or lockfiles are hand-edited while their source inputs remain conflicted.333- Stash-pop or orchestrated subagent merge conflicts are silently hand-resolved when the safer workflow is to surface the conflict, re-dispatch, or ask for a decision.334- Local-only, credential-adjacent, cache, temp, runtime, generated report, or provider files are staged without proving they are intentional tracked artifacts.335- Advisory artifacts such as plans, PR notes, dogfood reports, optimization logs, prior learnings, or release notes are treated as authority over current Git state.336- A browser, dogfood, optimization, or promotion workflow is resumed before the active conflict state is understood, verified, or deliberately blocked.337- Conflict markers remain in source, snapshots, docs, or generated output.338- The operation is continued with unresolved paths, skipped material checks, or unexplained verification gaps.339- A merge/rebase/cherry-pick is completed and then pushed without separate push/PR authorization.