AI-Guided Strategic Multi-Commit Cherry-Picking | Generated by AI

Home 2026.04

Question: Can we use a code assistant like Copilot to cherry-pick dozens of commits from branch A to branch B, and control conflict strategy (prefer theirs vs ours) per feature by prompting carefully?

Answer:

Yes — this is actually a very good use case for a code assistant. It helps especially when:

Your idea is correct. The assistant can act as a guided merge operator, while you define strategy per feature.


Why this works well

Cherry-picking many commits usually causes:

A code assistant can:


Example Workflow (Best Practice)

Step 1 — Define rules in prompt

Example:

We are cherry-picking commits from branch A into branch B.

Rules:
- For feature "payment", prefer theirs
- For feature "logging", prefer ours
- For config files, always prefer ours
- For new files, prefer theirs
- Do not remove existing API signatures
- Keep tests from both sides

This gives the assistant merge policy, not just commands.


Step 2 — Cherry pick sequentially

git cherry-pick <commit1>

When conflict happens:

Ask Copilot / assistant:

Resolve conflicts using rules:
- payment: theirs
- logging: ours
- config: ours
- new files: theirs

This is much safer than blindly using:

git cherry-pick -X theirs

because -X theirs applies globally, not selectively.


When this is MUCH better than git flags

Git only supports:

-X ours
-X theirs

But you want:

Only an AI/code assistant can reason per conflict.


Even better: batch strategy

You can tell assistant:

Cherry-pick these commits:

A1 A2 A3 A4 A5

Strategy:
- commits A1-A2: prefer theirs
- commits A3-A4: prefer ours
- A5: manual merge

This is very powerful.


Another strong pattern

Let assistant generate commands:

git cherry-pick A1
git checkout --theirs src/payment/*
git checkout --ours config/*
git add .
git cherry-pick --continue

This combines:


Important caution (you correctly noticed)

Prompt quality matters a lot.

Bad prompt:

fix conflict

Good prompt:

Resolve conflict.
Rules:
- Keep branch B logging system
- Use branch A payment implementation
- Preserve both test cases
- Do not change public interfaces

Much safer.


When this approach is especially useful


One more pro tip

Use no-commit mode:

git cherry-pick -n <commit>

Then let assistant resolve before commit.

This gives you full control.


Summary

Yes — your understanding is correct:

This is actually a very advanced Git workflow.


Back Donate