Skip to main content

Sync with the Target Branch

When the Target Branch moves ahead of a session's branch, the chat header shows Branch behind. When the session's pull request no longer merges cleanly, it shows PR has conflicts. Press Sync beside either label. The agent merges the Target Branch into the session's branch, resolves the conflicts and checks that the project still builds.

When to sync​

The label sits in the status row at the top of the chat, next to the branch name. It appears on Active and Under Review sessions.

LabelColorMeans
Branch behindYellowThe Target Branch has commits this branch does not have yet.
PR has conflictsRedThe pull request no longer merges cleanly into the Target Branch.

Once a session has a pull request, a branch that is behind also puts it in Needs you on the Home page, for its Assignee. See Home, Needs you and Activity.

Run Sync​

  1. Press Sync in the status row. In a narrow chat panel the label shrinks to a dot, and Sync stays beside it.
  2. Answer the agent if it asks about a conflict.
  3. Read the agent's reply.

If the agent is working when you press Sync, the request waits Up next and runs after the current turn. Your unsent message in the composer stays where it is.

Sync brings in the Target Branch, the branch set in Open PRs against in the project settings. When that setting is empty, it is the repository's default branch. Once the session has an open pull request, Sync brings in the branch that pull request merges into, and Branch behind compares against that branch. They differ only for a pull request that targets another branch, such as one stacked on another session's branch or retargeted on GitHub.

Answer a conflict question​

The agent settles most conflicts on its own by combining what each side meant. It asks you only when both sides changed the same thing for the same purpose, such as the same title text changed two ways.

It collects all such conflicts into one question. For each, it names the file and shows both versions. It offers to keep this branch's version, take the Target Branch's version, or use a resolution you describe. Answer in the chat and the agent finishes the sync. Messages, Up next and steering explains how answering works.

What you get​

  • A merge commit on the session's branch, such as "chore: sync with main". The agent makes it whatever your Commits preference says.
  • With the Commits preference on Automatic, the agent pushes the branch and the label clears. On Manual, the merge commit stays in the sandbox and the agent tells you. Press Push in the chat footer to publish it.
  • The app restarted on the merged code, with its setup run again.
  • A reply that lists what came in from the Target Branch and how each conflict was resolved. It also names the migrations and dependencies it reconciled, the checks it ran and the state of the app.

If the merged code needs an environment variable or a service that the project settings gained after this session started, the agent says so. Start a new session to get it.

The steps the agent follows are on /kosuke:sync-branch. You can also run that skill yourself by typing /kosuke:sync-branch in the chat, or $kosuke:sync-branch in a Codex session.

Next steps​