Skip to main content
Manage project branches. poly branch requires a subcommand: Examples:

poly branch list

List all branches in the project. Examples:
--json output shape:
With --archived, the shape is { "archived_branches": [...] } instead.

poly branch current

Show the current branch, and its parent branch if it isn’t main. Examples:
--json output shape:
If your local checkout doesn’t match a branch that still exists in Agent Studio (it may have been deleted or merged), both fields are null.

poly branch create

Create a new branch, sourced from your current branch by default. In the standard deployment mode, a new branch can only be sourced from main — if you aren’t currently on main, switch there first or pass --from main explicitly. Examples:
When --env live or --env pre-release is specified:
  • the version of the deployed environment is pulled into your local workspace
  • the new branch is created
  • that version is immediately pushed to the new branch, leaving a clean slate for hotfix changes
  • if there are local changes, the command fails unless --force is also passed
Use --env live with cautionBranching from a live deployment snapshot overwrites your local project with the live state. Merging this branch back to main may roll back changes introduced after the snapshot was taken.
--json output shape:

poly branch switch

Switch to a different branch. Omit branch_name for an interactive picker. Examples:
By default, switching replaces your project files with the target branch’s state, and refuses if you have uncommitted changes. --keep-files switches without touching your files, so the next poly push sends your working copy to the target branch. --create creates the branch if it doesn’t exist, sourced the same way as poly branch create: from your current branch, or from the branch given with --from. Together, they keep a project in a git repo on the Agent Studio branch matching the git branch: after git switch, the last example tracks the branch of the same name, creating it from main if needed, without overwriting what git checked out. --json output shape:
"created" is true when --create made a new branch. With --output-json-projection, a "projection" key containing the full project projection is added.

poly branch rename

Rename the current branch. main cannot be renamed. Examples:
--json output shape:

poly branch delete

Interactively select and delete one or more branches. main cannot be deleted.
  • Run without arguments to open an interactive checkbox prompt for selecting branches to delete.
  • Pass a branch name directly to skip the interactive prompt and delete that branch after confirmation.
Examples:
--json output shape — single branch:
"switched_to" is only present when the deleted branch was your current branch. Multi-select delete (no branch_name) reports a count instead:

poly branch restore

Restore a soft-deleted branch from the archive. Archived branch names aren’t unique, so restoring by ID is required in non-interactive use — find IDs with poly branch list --archived. Examples:
--json output shape:

poly branch merge

Merge the current branch into its parent (main, unless you branched from another branch). A message is required when merging into main. Examples:
If the merge has no conflicts, it completes immediately and the CLI switches your local checkout to the parent branch. If merging into main deploys to live while an experiment is running, it changes the live version the experiment compares against. The confirmation prompt names the experiment, and answering yes acknowledges it. With --force or --json, pass --acknowledge-experiment instead, or the merge is blocked. --json output shape:
On conflict or error, "conflicts" and/or "errors" arrays are added and the process exits non-zero.

Conflicts

If the merge has conflicts, the command prints a conflict table and exits non-zero. The table shows, per 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 both sides
  • Auto-mergeable — whether the auto-merged value contains any unresolved markers
If every conflict is auto-mergeable and you want to accept it, re-run with --interactive and accept the suggestions, or pre-populate --resolutions with the auto-merge values.

--interactive / -i

Interactive mode walks through each conflict and asks how to resolve it. For every conflict you can:
  • accept the auto-merge (when available)
  • pick the parent branch (ours): main, unless you branched from another branch
  • pick the branch (theirs)
  • pick base (revert to the original value)
  • open the value in $EDITOR/$VISUAL for free-form editing
After every conflict is answered, the merge is re-attempted automatically.
Set $EDITOR or $VISUAL before starting an interactive mergeInteractive mode shells out to your editor for multiline or long values, falling back to vi if neither variable is set. EDITOR="code --wait" (or your editor of choice) makes this much smoother.

--resolutions <source>

Supply pre-defined resolutions non-interactively. The source can be a JSON file path, a literal JSON string, or - to read from stdin. Combine with --interactive to seed a session — pre-defined choices apply automatically and you’re only prompted for the conflicts they don’t cover. Resolution file format — a JSON array of objects:
Run poly branch merge once to surface conflicts, then write a resolutions file addressing each path row.

Merging through the Agent Studio web UI

Switching to the branch and clicking Merge in the Agent Studio UI hits the same platform endpoint as poly branch merge — the result is identical either way.

poly branch sync

Bring the latest changes from the current branch’s parent (main, unless you branched from another branch) into the branch, without merging the branch back. Examples:
The checkout must have no unpushed changes. If the sync has no conflicts, it completes immediately and the CLI pulls the updated branch into your checkout. --json output shape:
On conflict or error, "conflicts" and/or "errors" arrays are added and the process exits non-zero. If the parent and the branch changed the same fields, the command prints the conflict table and exits non-zero. Resolve the conflicts the same way as for poly branch merge: "ours" keeps the parent’s value and "theirs" keeps the branch’s.

poly branch diff

Show changes made on a branch since it was created — its own local-vs-remote analogue is poly diff. Examples:
--json output shape:

poly branch review

Create a GitHub Gist of the changes on a branch since it was created — the branch-scoped analogue of poly review create. Examples:
--json output shape:

poly branch status

Show a branch’s status relative to its fork point — parent branch, who created it, whether it’s diverged, and its changed files. The branch-scoped analogue of poly status. Examples:
--json output shape:

poly branch history

Show the branches that has been merged into the current branch. Long listings are automatically paged through the system pager when stdout is a TTY; output piped to a file or another command is never paged. Examples:
--json output shape:
Last modified on November 27, 2026