Example result: Resolve a Git merge conflict safely
AI-generated example · Git · Merge Conflict
Updated

Resolve a Git merge conflict safely

This prompt explains what each side of a Git conflict was trying to do, then merges them so both changes survive. It also gives the git commands to finish the merge and a quick test to check nothing broke.

text-code-merge-conflict-resolve — claude — 94 words

Act as a senior developer helping me resolve a Git merge conflict.

What my branch does: [e.g. adds discount codes at checkout]
What the other branch does: [e.g. refactors checkout into smaller functions]

Conflicted file with markers:
[PASTE THE FILE WITH <<<<<<< ======= >>>>>>> MARKERS]

Explain what each side changed and why they clash. Then give me the merged version that keeps both intentions, and point out any line where you had to choose one side. Finish with the exact git commands to mark it resolved and a quick test to confirm nothing broke.

Describe what each branch was trying to do. The AI resolves conflicts much better when it knows the intent, not just the lines.

Get a better result

What you will get

An explanation of what each side changed and why they clash, a merged version that keeps both intentions, a note on any line where one side had to win, and the git commands and a test to finish.

Common mistake

The merge keeps only one side silently.

Fix: Keep the instruction to point out every line where a choice was made, and read those lines yourself.

Also watch for
  • The merged code compiles but behaves differently. Ask for a short test or a manual check for each branch’s feature, such as applying a discount code in the refactored flow.
  • You paste only the conflict markers without context. Include a sentence about what each branch intended and a few lines around the conflict. Intent decides the right merge.
Try a variation: ask for a safer branch plan

Add “suggest how we could avoid this clash next time, such as merging the refactor first”. Small, frequent merges usually cause fewer conflicts.

Still not right? Reply with this

List each conflict one by one, saying which side added what, then give the merged block for each in order.

Guides that use this prompt

More chat & writing prompts

See all 465 →