Sub topic 9
Day to day: queueing and dequeueing pull requests
This chapter covers what developers and maintainers do once a merge queue is running. It assumes you know GitHub pull requests, required reviews, and required status checks. It also assumes the queue is already enabled and your workflows already run on the merge_group event, as covered in earlier chapters.
What changes on the pull request page
With a merge queue on, the usual merge button no longer merges directly. It starts the queue process instead. What you see depends on the pull request's state:
| Pull request state | Button label | What clicking does |
|---|---|---|
| All requirements met (reviews, required checks, conversations resolved) | Merge when ready | Adds the pull request to the queue immediately |
| Some requirements still pending | Merge when ready | Enables auto-merge, so the pull request joins the queue once the requirements are met |
| Already queued | Remove from queue | Takes the pull request out of the queue |
The exact label can vary with the state of the pull request and the GitHub UI version. The behavior is the same: the pull request is not merged until the queue has tested it.
Two points are easy to miss:
- The pull request branch is checked first. A pull request must satisfy your branch protection or ruleset requirements before it can enter the queue. The queue adds a second round of checks on the merge group branch. It does not replace the first.
- You choose no merge method. The queue settings fix the method (merge, squash, or rebase). Pull request authors don't pick one per pull request.
The lifecycle of a queued pull request
The pull request page shows a status line such as its position in the queue and whether its group is awaiting checks. The queue itself has a page for each protected branch. Open the repository's Pull requests tab and follow the merge queue link for the branch, or go to https://github.com/OWNER/REPO/queue/main. That page lists entries in order, shows which merge group each belongs to, and shows whether checks are running.
Adding a pull request to the queue
From the web UI
Click Merge when ready on an eligible pull request. This is the normal path for most people.
From the GitHub CLI
gh pr merge works with queues. In a repository with a queue, it adds the pull request to the queue instead of merging directly:
gh pr merge 482If requirements are still pending, request auto-merge. The pull request joins the queue once they are met:
gh pr merge 482 --autoDon't rely on --squash, --rebase, or --merge here. The queue's configured method decides how the commit lands on the base branch. To cancel a pending auto-merge:
gh pr merge 482 --disable-autoFrom the GraphQL API
Automation can use the enqueuePullRequest and dequeuePullRequest mutations. You need the pull request's node ID first:
PR_ID=$(gh pr view 482 --json id --jq .id)
gh api graphql -f query='
mutation($id: ID!) {
enqueuePullRequest(input: {pullRequestId: $id}) {
mergeQueueEntry { position state }
}
}' -f id="$PR_ID"The mutation returns a queue entry. Its position and state fields are useful for scripts that report where a pull request stands. The call fails if the pull request does not meet the branch's requirements.
Removing a pull request from the queue
People with write access to the repository can remove a pull request. Use the Remove from queue button on the pull request page, or the entry's menu on the queue page. From the API:
gh api graphql -f query='
mutation($id: ID!) {
dequeuePullRequest(input: {id: $id}) {
mergeQueueEntry { state }
}
}' -f id="$PR_ID"Remove a pull request on purpose when:
- You found a bug after queueing.
- The change depends on something that has not shipped.
- A release freeze started.
- Another pull request must land first, and ordering matters.
Removing one entry affects the others. Any pull request behind it was tested on a branch that included the removed change, so GitHub rebuilds those merge groups without it and reruns their checks. A removal near the front of a long queue is therefore expensive. Remove early, and avoid doing it casually.
Automatic removals
GitHub also removes pull requests without anyone clicking. The common triggers are:
- Failed required checks on the merge group branch.
- A new push to the pull request branch. The tested commit no longer matches the pull request head, so the entry is dropped.
- A merge conflict with the base branch or with changes queued ahead of it.
- A check timeout. If required checks do not report within the configured response timeout, the entry fails.
- Closing the pull request or converting it to a draft.
- Losing a requirement, such as a dismissed review after new commits, when your rules dismiss stale approvals.
GitHub notifies the author, and the pull request timeline records the removal and a reason. Read the reason before re-queueing. The fix depends on it: a flaky test needs a rerun, while a real conflict needs a rebase and fresh review.
Re-queueing after a removal
After a removal, the pull request returns to an ordinary open pull request. Follow these steps:
- Read the timeline entry and open the failed check on the merge group commit. Its logs name the failing job.
- Fix the cause. For a real failure, push a fix to the pull request branch. For an unrelated flaky test, rerun the failed job if it can be rerun, or re-add the pull request without a push.
- Wait for reviews and required checks to pass again on the pull request branch.
- Click Merge when ready again.
A re-queued pull request goes to the back of the line. If the failure came from the pull request's own code, this is correct. The change should be tested again with whatever has landed since.
Jumping the queue
For urgent fixes, you can move a pull request to the front. The queue page offers a jump option on queued entries. Where your repository gives you permission to bypass, you may also see an option to merge without waiting for requirements.
These options have different costs:
- Jumping to the front still tests the pull request on the merge group branch. It is placed first, so it is tested against the base branch alone. Every entry that was ahead of it is rebuilt on top of it, and its checks restart.
- Bypassing requirements skips the queue's protection. Use it only for real emergencies, such as a broken
mainthat blocks all merges. It reintroduces the stale-main risk the queue was built to remove.
Agree on a team rule for both options. A queue works only if people trust it, and frequent jumping teaches everyone to expect delays.
Reading the queue to plan your work
The queue page tells you three things:
- Position. The number of entries ahead of you.
- Group state. Whether the group is waiting on checks, building, or ready to merge.
- Time cost. Roughly, the total time to merge is the wait for earlier groups plus your group's check duration.
If your pull request is blocking a release or another pull request, check the queue before you queue it. A queue five groups deep with 20-minute checks means more than an hour of waiting. For long waits, use auto-merge and work on something else instead of watching the page.
A short checklist for authors
- Get approvals and green pull request checks first.
- Click Merge when ready, or run
gh pr merge --auto. - Don't push to the branch while queued.
- If removed, read the timeline reason, fix the cause, and queue again.
- Remove your own pull request quickly if you spot a problem. The sooner you do, the fewer rebuilds it causes.
Exercise
You queued a pull request and notice a bug in it while five other pull requests are queued behind it. You push a one-line fix to the branch. What happens, and what should you have done instead?
Show answer
The push removes your pull request from the queue because the tested commit no longer matches the head. The entries behind it have their merge groups rebuilt without your change, and their checks rerun. A better approach is to remove the pull request from the queue explicitly as soon as you spot the bug, push the fix, wait for reviews and required checks again, and then queue it again. Removing it first has the same rebuild cost, but it makes your intent clear and avoids a surprise push-triggered removal.
Exercise
A teammate says the merge method flag gh pr merge 482 --rebase will make their pull request land as a rebase even though the queue is configured for squash. Is that right?
Show answer
No. When a merge queue is enabled, the queue's configured merge method decides how the commit lands on the base branch. Per-pull-request method flags do not override it. The command only adds the pull request to the queue.