Merge a branch into its parent with poly branch merge, including interactive and pre-defined conflict resolution. On the new deployment system, merging a Branch into main publishes it to Live.
poly branch merge is the CLI-native counterpart to merging in the Agent Studio web UI. It brings everything you’ve changed on the current branch back onto its parent (main for a Branch, or the parent Branch for a Sub-branch). It surfaces any conflicts in a structured table and lets you resolve them either interactively or from a JSON file.
How the CLI maps to the new deployment system
mainis the Live version on projects using the new deployment system. A branch is a Branch, cut from Live. A branch created from another branch is a Sub-branch.poly branch mergemerges into the parent. Merging a Branch intomainpublishes it to Live. Merging a Sub-branch merges it into its Branch.poly branch syncis Sync. It pulls the parent’s changes into your branch. Run it before merging if the parent has moved on.poly branch tagmoves the current Branch to Staging (pre-releasein the CLI).poly branch untagremoves it.poly deployments promote, and the old sequence of promoting from sandbox to pre-release to live, apply only to projects that have not yet moved to the new deployment system.poly deployments rollbackrolls Live back on new-system projects.
poly branch section of the CLI reference. For the team-level guardrails around branching and merging, see Multi-user workflows and guardrails.
When to use it
You’ll typically reach forpoly branch merge at the end of a feature loop:
- Create a branch with
poly branch create my-feature(seepoly branch create). - Iterate locally, pushing with
poly push(see Working locally). - Test with
poly chatagainst the branch’s pushed state. - Merge back to
mainwithpoly branch merge '<message>', described on this page. On the new deployment system this publishes the Branch to Live. - On projects that have not yet moved to the new deployment system, promote the merged state with
poly deployments promote.
Basic usage
poly branch merge requires a merge message and merges the current branch into its parent (main for a Branch, or the parent Branch for a Sub-branch). Switch to the source branch first if you aren’t on it.
main. Run poly pull afterwards if you need to refresh local state.
Conflicts
If the merge has conflicts, the command prints a conflict table and exits with a non-zero status code. The table shows, for each conflicting field:- Path: the resource and field that conflicts (for example
topics > Booking > content) - Base / Ours / Theirs: the original value and the two competing values
- Auto-merged value: what the ADK would produce by line-merging the two sides
- Auto-mergeable: whether the auto-merged value contains any unresolved markers
--interactive and accept the suggestions, or pre-populate --resolutions with the auto-merge values.
--interactive / -i
Interactive mode walks you through each conflict and asks how to resolve it. For every conflict you can:
- accept the auto-merge (when available)
- pick
main(ours) - pick branch (
theirs) - pick
base(revert to the original value) - open the value in your
$EDITORor$VISUALfor free-form editing
--resolutions <source>
Use --resolutions to supply pre-defined resolutions non-interactively. The source can be:
- a path to a JSON file
- a literal JSON string
-to read JSON from stdin
--resolutions with --interactive to seed an interactive session. Pre-defined choices are applied automatically and you’ll only be prompted for the conflicts they don’t cover.
Resolution file format
--resolutions expects a JSON array of objects:
You can capture the structure of a resolution file by running
poly branch merge once to surface the conflicts, then writing a JSON file that addresses each path row.
After a successful merge
- The CLI switches your local checkout to
main. - Run
poly pullif you need to refresh local state to match the post-mergemain. - Run
poly chatagainstmain(which falls back to the sandbox environment) to smoke-test the merged result. On the new deployment system, merging a Branch intomainpublishes it to Live straight away, so test the Branch withpoly chatbefore you merge. - On projects that have not yet moved to the new deployment system, follow up with
poly deploymentsto promote the merged state to a live environment. On the new deployment system the merge has already published the Branch. If you need to undo it,poly deployments rollbackrolls Live back.
Merging through the Agent Studio web UI
You can also merge through the Agent Studio interface:- Open the project in Agent Studio.
- Open the Branch or Sub-branch.
- Click Publish in the top-right corner for a Branch, or Merge for a Sub-branch.
Troubleshooting
Related references
Tests
Validate agent behavior with conversation tests before merging.
Tooling
IDE extensions and AI coding tools that integrate with the ADK workflow.
Multi-user workflows and guardrails
How branches, merges, and validation interact across a team.

