Skip to content
Source
Sign inSign up

Update your branch

Issues and pull requests / Pull requests

Bring your branch up to date

The base branch moved on, and your pull request is behind it. You want the new commits of the base branch in your branch, with one click.

3 min read

You need write access to the repository of the head branch.

Note

For a pull request from a fork, the author can allow maintainer edits. Then people with write access to the base repository can update it too.

1. Update the branch

  1. Open the pull request. Its merge box shows the row Behind main, with Update branch.
  2. Click Update branch. The forge merges the base branch into your branch.

For a rebase, click the arrow next to Update branch, then click Update with a rebase.

In a terminal:

src pr update-branch 7
src pr update-branch 7 --rebase

Done

Your branch has the new commits of its base branch, and you did not leave the page.

When the forge refuses the update

  • If the two branches conflict, the forge refuses the update. Merge the base branch on your machine, then push. The merge box gives the commands under Resolve the conflicts. See Resolve the conflicts.
  • If someone pushed to the branch after you opened the page, the forge refuses the update. Load the page again.

On a pull request from GitHub

A contributor opened the pull request on GitHub, and GitHub sync brought it here. Its head branch is on GitHub, often on the contributor's fork. You want that branch to get the new base, so the contributor sees it on GitHub too.

Update branch does this for you. The forge makes the merge or the rebase, then pushes it to the head branch on GitHub with your own GitHub token.

You need:

  • Write access to the repository here.
  • GitHub connected for sync. See Connect GitHub.
  • For a pull request from a fork: the author allows edits from maintainers on GitHub.

Then:

  1. Open the pull request.
  2. Click Update branch, or Update with a rebase. In a terminal, run src pr update-branch 7.

GitHub takes the push first. The head here moves only after that. A rebase overwrites the branch on GitHub only while the branch is still at the commit that you saw.

Only a person can do this. An agent session or a job token is refused.

The forge refuses the update, and shows why, when:

  • You did not connect GitHub. Connect it in Settings, Connected accounts.
  • GitHub sync is off, or you have no write access here.
  • The pull request is not open on GitHub, or its fork is gone.
  • The author does not allow edits from maintainers on GitHub, or the head branch is a release branch.
  • The head branch on GitHub moved since you opened the page. Wait for sync to bring it down, then try again.

The branch rules on GitHub can also refuse the push. Then nothing changes here.

Later: REST and MCP

An agent or a script does the same work over REST or MCP, with the same rules. The REST paths are under /api/v1/repos/{owner}/{repo}.

You want toRESTMCP tool
Bring the branch up to datePOST /pulls/{n}/update-branch, with { "rebase", "sha" }update_pull_branch

A conflict in a branch update gets 409. On a pull request from GitHub, a call with an agent session or a job token is refused.