GitHub merge queue: setup, merge_group and the settings that matter
Every pull request is tested against what main will be once it merges, not what main was when it opened. What the queue checks, how to switch it on, and why it stalls.
Shipped by Agents Editors · Checked against GitHub's documentation on
What a merge queue does
A pull request's checks run on its own branch. By the time it merges, main may have moved: two pull requests can each pass on their own and still break the build together. GitHub's older answer is the branch protection setting "Require branches to be up to date before merging", which makes each author update their branch and wait for checks again before merging. On a busy branch that turns into a race to rebase.
A merge queue gives the same guarantee without the race. Once a pull request has passed its required checks, anyone with write access adds it to the queue. GitHub then builds a temporary branch that holds the latest main, every pull request ahead of it in the queue, and this one, runs the required checks on that branch, and merges only if they pass. Pull requests merge in first-in, first-out order.
| Up-to-date branches required | Merge queue | |
|---|---|---|
| What is tested before merging | The pull request on top of the main it was last updated with | The pull request on top of the latest main and everything queued ahead of it |
| Who updates the branch | The author, each time main moves | GitHub, on a temporary branch |
| Checks run in parallel for several pull requests | No: each must be updated and checked again after the one before it lands | Yes, up to the build concurrency you set |
GitHub describes the queue as most useful on branches where many pull requests from many people merge each day. That is also the shape of a repository where coding agents open pull requests: more of them, smaller, and arriving faster than anyone wants to rebase by hand.
Where it is available
GitHub's documentation lists merge queues as available in public repositories owned by an organization, and in private repositories owned by organizations on GitHub Enterprise Cloud. Repositories on a personal account do not have them. Plans change, so check GitHub's plans page for your own repository before you plan around it.
Repository administrators turn it on. A merge queue cannot be enabled on a branch protection rule whose branch name pattern uses a wildcard (*).
Make CI run on merge_group first
Do this before you require the queue. When a pull request joins the queue, GitHub sends a merge_group event, not pull_request and not push. A workflow that does not listen for it never runs for the queue, the required check is never reported, and the merge fails. Add merge_group beside your existing triggers in every workflow that reports a required check:
on:
pull_request:
branches: [main]
merge_group:
types: [checks_requested]
branches: [main]checks_requestedis the only activity type today. Naming it keeps the workflow from running on any type GitHub adds later.branchesonmerge_groupfilters by the branch the queue merges into, so[main]means merge groups that targetmain.- In a
merge_grouprun,GITHUB_SHAandGITHUB_REFare the merge group's commit and ref, not the pull request's. The temporary branches start withgh-readonly-queue/<base branch>/. - CI outside GitHub Actions has no
merge_groupevent: configure it to run on pushes to branches that start withgh-readonly-queue/<base branch>.
The check names have to match. Branch protection asks for a check by name, and the queue waits for a check with that name on the merge group's commit. If the job that reports the required check is renamed, or only runs under
pull_request, the queue waits for a check that never arrives.
Require the queue
Merge queue and pull request checks are configured together, in a branch protection rule or a ruleset for the base branch. Turn on "Require merge queue" there, alongside the required status checks you already have. Once it is on, merging that branch goes through the queue: the merge box offers "Merge when ready" instead of a merge button.
- The "Merge when ready" button can be clicked before checks pass. GitHub then turns on auto-merge and queues the pull request once its requirements are met, even if "Allow auto-merge" is off for the repository.
- From the command line,
gh pr mergeadds the pull request to the queue when its required checks have passed, and turns on auto-merge when they have not. To queue only if it can be queued right now, use theenqueuePullRequestGraphQL mutation, which returns an error saying why when it cannot. - Removing a pull request from the queue, and viewing the queue, are done on GitHub.com: the "Remove from queue" button on the pull request, or the queue page linked from the repository's "Branches" page.
- Administrators may still be allowed to merge directly with "Merge without waiting for requirements to be met", if the branch protection settings permit bypassing.
The queue's settings
Requiring the queue unlocks these settings on the same rule:
| Setting | What it controls | When to change it |
|---|---|---|
| Merge method | Merge, rebase or squash for every queued pull request | Match what the branch used before the queue |
| Build concurrency (1–100) | How many merge_group events are dispatched at once, and so how many CI builds the queue runs in parallel | Lower it if queue builds crowd out other CI on your runners; raise it if the queue is waiting on its own limit |
| Only merge non-failing pull requests | On: every pull request in a group must pass. Off: a pull request that failed can still merge if the last pull request in its group passed, since that run tested the combined changes | Turn off only if intermittent failures keep holding up the queue, knowing it trusts the last run in the group |
| Status check timeout | How long the queue waits for CI before treating the checks as failed | Longer than your slowest required job, with room for time spent waiting for a runner |
| Merge limits: maximum | The most pull requests merged into the base branch at once | Cap it when each merge deploys and you want small deploys |
| Merge limits: minimum and wait time | The fewest pull requests to merge at once, and how long to wait for that many before merging fewer | Raise it when each merge starts a long build or deploy on main |
Merge limits do not combine builds. They change how many already-passing groups land on the base branch together, not how many pull requests one CI run tests.
What happens when a check fails
Each group in the queue builds on the one before it. Say pull request #1 is queued, then #2. GitHub tests main + #1 on one temporary branch and main + #1 + #2 on another, at the same time. If both pass, both merge. If #1 fails, GitHub removes it from the queue, rebuilds #2's branch as main + #2, and runs the checks again; #2 merges if that run passes.
That rebuild is the cost of a failure in the queue: every pull request behind the one that failed is tested again. The same happens when someone uses the option to jump to the top of the queue, which GitHub warns rebuilds everything in progress and slows merging if used often.
GitHub removes a pull request from the queue when:
- CI reports a failed required check for its merge group.
- No successful result arrives before the status check timeout.
- Someone removes it, in the queue view or through the API.
- A branch protection failure cannot be resolved automatically, such as a conflict with the base branch.
The pull request's timeline says which of these it was.
Why pull requests get stuck
- No
merge_grouptrigger. The most common one. The pull request passes, joins the queue, nothing runs, and it is removed at the timeout. Check every workflow that reports a required check. - Path filters on a required workflow. GitHub documents that a workflow skipped by path or branch filters leaves its checks pending, which blocks merging. A required check has to run on every merge group; move the filtering inside the job, or make the required check a job that always runs.
- A required job skipped because a job it
needsfailed. GitHub notes the skipped job may not block merging. Give the required jobif: always()and have it fail when any job it needs did not succeed, so the check reports the real verdict. - Concurrency groups that ignore the ref. Each merge group has its own
github.ref, so a group built fromgithub.ref, as in the concurrency guide, keeps merge group runs apart. A fixed group name such asciputs them all in one group, where a newer run replaces the waiting one and the queue waits for a result that was cancelled. - Cancelling on the wrong event. Keep
cancel-in-progresstopull_requestevents. A cancelled merge group run is not a pass, and the pull request leaves the queue. - A timeout shorter than the real wait. The timeout counts time a job spends waiting for a runner, not only time running. On a busy account the queue can time out on checks that would have passed.
The queue moves at the speed of CI
A merge queue adds a full required-check run between "ready" and "merged" for every pull request, and repeats it for everything behind a failure. How long that takes is how long your required jobs take on the merge group's commit, plus any wait for a runner. Build concurrency lets several groups run at once, but each still waits for its own run to finish.
So the levers are the usual ones: fewer stale runs competing for runners, warm caches, jobs split to run in parallel, and runners sized to the job. Keep the merge group run the same set of checks as the pull request run, so the verdict that lands on main is the one you would have trusted on the pull request. The posts below cover each of these.
Questions
Do I need merge_group if my workflow already runs on push to main?
Yes. The queue tests a temporary gh-readonly-queue/ branch before anything reaches main, and GitHub Actions only runs for it on the merge_group event. A push trigger for main runs after the merge, too late for the queue.
Why was my pull request removed from the merge queue?
A required check failed or was never reported for its merge group, the status check timeout ran out, someone removed it, or a branch protection failure such as a conflict could not be resolved. The pull request's timeline names the reason.
Can a merge queue be used on a private repository?
GitHub's documentation lists merge queues for private repositories only in organizations on GitHub Enterprise Cloud, and for public repositories in any organization. Check GitHub's plans page for the current terms.
Does the merge queue run my checks twice?
Yes: once on the pull request's own branch, which must pass before it can be queued, and again on the merge group, which tests it with the latest base branch and the pull requests ahead of it. A failure ahead of it in the queue means its merge group is built and tested again.
Can coding agents use the merge queue?
Anything that can run gh pr merge or call the GraphQL API with write access can add a pull request to the queue; the queue still runs the required checks before anything merges. Removing a pull request from the queue is done on GitHub.com, not through GitHub CLI.



