Skip to main content

Claude/ChatGPT Prompt to Resolve a Nasty Git Merge Conflict Safely

Resolve a nasty Git merge conflict with a structured, hunk-by-hunk plan that explains each side and catches the semantic conflicts Git silently won't flag.

Fill in the placeholders

Edit the values, then copy your finished prompt.

Your Prompt
prompt.txt

                                

What this prompt does

This prompt frames the model as a senior engineer who resolves gnarly merge conflicts without breaking behaviour, instructing it to specify the resolution tightly enough to apply and not rewrite unrelated lines. Three placeholders focus it: [branch_a] and [branch_b] (the two sides being merged) and [file] (the conflicted file to resolve).

The structure works because the dangerous conflicts are semantic, not textual — code that merges cleanly but behaves wrong, like a renamed function or a flipped default. By demanding a per-hunk breakdown explaining which side to keep and why, a unified resolution for [file], explicit flags for semantic conflicts, the specific tests mapped to the changed behaviour, and a safe-abort note, the prompt makes you reason hunk by hunk instead of blindly accepting one side. The mapped tests catch the conflicts that compile fine but page you at 2am. Naming [branch_a] and [branch_b] gives the model the context to explain each side's intent, so it can argue why one wins rather than picking arbitrarily.

When to use it

  • Two branches touched the same file and git merge left conflict markers you need to reason through.
  • You are merging shared backend code where a wrong default could silently change behaviour.
  • You want a per-hunk explanation of which side to keep rather than guessing.
  • You need semantic conflicts flagged — renames or changed defaults Git will not catch.
  • You want the specific tests to run mapped to what actually changed.
  • You want a safe-abort path (git merge --abort) if the resolution looks wrong.

Example output

Expect three sections in order: the hunk-by-hunk decisions (which side of [branch_a] vs [branch_b] to keep for each conflict in [file], and why), then the full resolved file with brief comments at any non-obvious merge decision and explicit flags on semantic conflicts, then the test commands to run mapped to the changed behaviour. A safe-abort note explains how to bail out with git merge --abort if the result looks off.

Pro tips

  • Give the model the real [file] content with conflict markers; it can only reason hunk by hunk if it sees both sides.
  • Run the mapped tests immediately after resolving — the conflicts that compile fine are exactly the ones that break behaviour quietly.
  • Pay attention to the semantic-conflict flags; a function renamed on [branch_a] but called the old way on [branch_b] will merge clean and still be wrong.
  • If the resolution feels uncertain, take the git merge --abort path rather than committing a guess.
  • Tell it not to touch unrelated lines so the diff stays reviewable and you can trace every change to a real merge decision.
  • Ask for a comment at any non-obvious merge decision so the next reader understands why one side of [file] survived.
  • When a hunk combines logic from both branches, double-check the merged version against each side's intent rather than assuming concatenation is correct.

Frequently Asked Questions

Does this catch conflicts Git misses?
That is the focus. Git only flags textual overlaps, so deliverable three explicitly calls out semantic conflicts — code that merges cleanly but behaves wrong, like a renamed function or a changed default that one side still relies on.
Will it rewrite parts of the file I did not touch?
No. The prompt instructs the model not to rewrite unrelated lines, keeping the resolution surgical so the resulting diff is reviewable and every change traces back to an actual conflict decision.
How do I know which tests to run after merging?
Deliverable four maps specific tests to the behaviour that changed in `[file]`. Running those immediately is the safeguard, since a clean compile says nothing about whether the merged logic still does the right thing.
What if the resolution looks wrong?
There is a safe-abort note showing how to bail out with `git merge --abort`, which resets you to the pre-merge state. That lets you back out cleanly instead of committing a resolution you are unsure about.
Engr Mejba Ahmed

Need this built for real?

Engr Mejba Ahmed

AI Developer · Software Engineer

I'm Mejba — I design and ship production AI systems, automations, and full-stack apps. If you want this turned into a working solution for your team, let's talk.

More in Git & GitHub Prompts

Engr Mejba Ahmed

Engr Mejba Ahmed

Claude Code Expert · Online

👋

Hey there!

Quick Actions

WhatsApp Instant reply

Chat on WhatsApp

+880 1723 741224 · Instant reply

Popular Questions

Engr Mejba Ahmed is connected
Engr Mejba Ahmed is typing...
Engr Mejba Ahmed avatar

✉ Want me to follow up? Drop your email

Engr Mejba Ahmed avatar

📞 Connect Directly

Choose how you'd like to reach me

WhatsApp

+880 1723 741224

Email

[email protected]

✓ Details sent! I'll get back to you shortly.

Powered by OpenAI

335+

Blog Posts

25

AI Courses

63

Projects

Services & Expertise

Pricing & Process

Learning & Resources

Connect & Support