Skip to content
Source
Sign inSign up

Merge with the queue

Issues and pull requests / Pull requests

Merge pull requests one at a time with the merge queue

Several pull requests are ready to go into main, and you wait for the checks of each one before you click merge. If a branch rule requires an up-to-date branch, each merge also makes the next pull request out of date.

10 min read

The merge queue does this work for you. You add each pull request to the queue once. The forge then merges them one at a time, in the order that people added them.

You need write access.

1. Add a pull request to the queue

  1. Open the pull request.
  2. In the merge box in the right column, pick Create a merge commit, Squash and merge or Rebase and merge.
  3. Click Add to merge queue. It is under the merge method.
  4. If necessary, change the commit title and message. Then click Confirm add to merge queue.
The merge box of a pull request, with the merge button, the merge method and Add to merge queue

The merge box now says In the merge queue: position 1 of base main. Below it, one line says what the queue does now, and one line says who added the pull request.

  • If you add a pull request again, it keeps its place. Your method and your commit text replace the old ones, and the queue merges it as you.
  • A pull request is in the queue or has merge when ready on, never both. When you add it to the queue, merge when ready turns off. When you turn on merge when ready, the pull request leaves the queue.

Important

The forge refuses a draft, a pull request that is not open, and a pull request from GitHub sync. It also refuses a pull request that sits on another open pull request in a stack. Merge the pull request below it first.

2. Let the queue merge it

Each base branch has its own queue. The pull request that was added first is at the front. Only the front pull request moves, and the others wait.

At the front, the queue does these steps as the person who added the pull request:

  1. If the queue must update the branch, the forge merges the base branch into it. No model does this step.
  2. If this merge has conflicts, an agent of the factory resolves them. An admin must turn it on. See Resolve conflicts with an agent.
  3. The queue waits for the checks of the head commit.
  4. When every check passed, the forge merges the pull request with the method and the commit text of the person who added it.

Then the next pull request is at the front.

Note

The queue updates the branch only when it must. That is when a branch rule requires an up-to-date branch and the branch is behind. It is also when the branch has conflicts, or when the forge has not checked for conflicts yet. In all other cases, the queue merges the branch as it is, with no merge commit of the base branch.

The merge box says what the queue does now:

The merge box saysMeaning
Waiting for its turn.The pull request waits for the front of the queue.
Updating the branch with main.The forge merges the base branch into the head branch, because a branch rule requires it or the branch has conflicts.
Resolving conflicts.The Keep green agent works on the conflicts.
Waiting for checks.The checks of the head commit run.
Merging.The forge merges the pull request now.
  • The merge has the same rules as the merge button: the branch rules and the required checks. While a branch rule refuses the merge, the pull request stays at the front.
  • If a check fails, and Fix failing CI is on and can still run on the head commit, the queue waits for its fix.
  • A push to the branch by someone with write access keeps the pull request in the queue. The queue then waits for the checks of the new commit.

3. See the queue

  1. Open the repository, then Pull requests.
  2. Above the list of open pull requests, find the block Merge queue: main. Each base branch that has a queue has its own block.
The pull request list under the block Merge queue: main, whose front row shows the badge Waiting for checks

Each row shows the position, the pull request and who added it. The front row also shows what the queue does now. When no pull request is in a queue, the block is not there.

In the list below the block, each queued pull request has a badge with its position, such as 3rd in merge queue. The pull request page shows the same badge next to its state. The block and the badges change when the queue changes, so you do not have to reload the page.

4. Take a pull request out

  • In the merge box, click Remove from queue.
  • Or, in the block Merge queue: main, click Remove in the row of the pull request.

The person who added a pull request can take it out, and so can people with write access. The next pull request then moves up.

The timeline shows who added the pull request to the queue, and who removed it.

Done

You add a pull request once. The forge waits for its checks and merges it, then starts on the next one. It first brings the branch up to date with its base branch when a branch rule requires it, or when the branch has conflicts. When a pull request leaves the queue, its timeline says why.

When a pull request leaves the queue

Your pull request was in the queue, and now it is not. Open it and read the timeline. The line "removed this pull request from the merge queue" gives the reason. For most reasons, the bot also posts a comment that says how to add it again.

The branch needs a change:

The timeline saysWhat to do
because it has conflicts and the merge-queue agent is offThe agent is off, or it did not start. Merge the base branch into your branch on your machine, then push. Then add the pull request again.
because the merge-queue agent could not resolve the conflictsResolve the conflicts on your machine, then push. Then add it again.
because its checks failedA check failed, and Fix failing CI did not fix it. Fix the check, then push. Then add it again.
because its checks did not finish in timeThe checks of its head did not finish within the merge queue timeout. See Check timeout.
because its branch could not be updated with the base branchThe forge failed to merge the base branch into your branch. For example, the branch is in a fork that does not allow edits from maintainers. Run src pr update-branch 7, or merge the base branch on your machine. Then add it again.
because someone without write access pushed new commitsNew commits came from someone without write access. Each push to a fork counts as such a push. A CI fixup() commit in a fork counts too, unless a person with write access applied it. Read the new commits, then add it again.

A person must add it again:

The timeline saysWhat to do
because the person who added it can no longer mergeThat person lost the permission to merge. Someone with write access adds the pull request again.
because an agent never merges into the default branchAn agent added it, and its base is the default branch. A person adds it again.

Someone took it out:

The timeline saysWhat happened
because the pull request was closedThe pull request is closed. Reopen it, then add it again.
because merge when ready was turned onMerge when ready now merges it. The queue does not.

The line "removed this pull request from the merge queue" with no reason means that a person took it out.

Check timeout

A pull request at the front of the queue waits for its checks. If a check never starts or never reports, every pull request behind it waits too. For example, a run from a fork can wait for approval.

So the queue gives the checks of the front a time limit, 60 minutes by default:

  1. The timer starts when the queue starts to check the head of the front.
  2. A new head starts the timer again, for example an update of the branch or a fix from Fix failing CI.
  3. If the checks do not finish in time, the pull request leaves the queue, and the bot comments why. The next pull request becomes the front.

To change the limit, give a whole number of minutes from 1 to 120:

src ci settings --queue-timeout 90
src ci settings --clear-queue-timeout

The second command goes back to 60 minutes. You can also change it on the CI settings page of the repository, or with mergeQueueTimeoutMinutes in REST and MCP. See CI reference.

Resolve conflicts with an agent

Without an agent, a pull request with conflicts leaves the queue, and a person resolves the conflicts by hand. With the Keep green agent and its step Resolve conflicts in the merge queue, the queue resolves them and goes on. A repository admin turns it on. See Let an agent resolve conflicts in the merge queue.

In a terminal or from an agent

Your agent can queue its pull request with no browser:

src pr queue add 7 --squash
src pr queue list
src pr queue list --base main --json number,title,position,phase
src pr queue remove 7
  • src pr queue add takes --merge (the default), --squash or --rebase. --subject and --body set the text of the merge commit. A rebase takes no text.
  • With no number, src pr queue add and src pr queue remove use the pull request of the current branch.
  • src pr queue list shows each queue, front first. --base shows the queue of one base branch.

Over REST or MCP, the same rules apply. The REST paths are under /api/v1/repos/{owner}/{repo}.

You want toRESTMCP tool
List the queuesGET /pulls/queue, with ?base=main for one base branchlist_merge_queue
Add a pull requestPUT /pulls/{n}/queue, with { "merge_method", "commit_title", "commit_message" }add_to_merge_queue
Take a pull request outDELETE /pulls/{n}/queueremove_from_merge_queue
  • merge_method is merge, squash or rebase, and merge when you leave it out. The commit text is the text of the pull request page when you leave it out.
  • The forge refuses a draft, and the other pull requests of step 1, with 422. A removal by a person who did not add the pull request and has no write access gets 403.
  • The answer of PUT and DELETE is { "number", "state", "mergeQueue" }. mergeQueue is { "addedBy", "method", "addedAt", "base", "position", "phase" }, or null when the pull request is not in the queue. GET /pulls/{n} has the same mergeQueue.
  • The answer of GET /pulls/queue is { "queues" }. Each queue has its base and its entries, front first.
  • If an agent adds a pull request into the default branch, the pull request leaves the queue at the front. An agent never merges into the default branch, so a person must add it.