Sub topic 4
Turning on the merge queue
This chapter assumes you can already create branch protection rules or rulesets, and that you know which status checks your repository requires. You will enable the queue, check who can use it, and confirm it is active. Making workflows report checks in the queue is covered in a later chapter.
Check that your repository qualifies
Merge queues are not available everywhere. Before you look for the setting, confirm three things:
- The repository belongs to an organization. Personal repositories cannot use a merge queue.
- The repository is public, or it is private on a plan that includes merge queues (GitHub Enterprise Cloud).
- You have admin permission on the repository, because the queue is configured in repository settings.
If the option is missing, the cause is usually the account type or the plan, not a misconfiguration.
Two ways to enable it
You can turn the queue on in a branch protection rule or in a repository ruleset. Both apply the queue to the branches you target.
| Approach | Where | Notes |
|---|---|---|
| Branch protection rule | Settings, Branches, edit the rule for `main` | Fits repositories that already use classic rules |
| Repository ruleset | Settings, Rules, Rulesets, New branch ruleset | Can be exported, layered, and applied through the API |
Choose one and stay with it for a branch. Two sets of rules on the same branch are harder to reason about, because GitHub combines them and the strictest setting wins.
Using a branch protection rule
- Open the repository's Settings, then Branches.
- Edit the rule for
main, or add one with the branch name patternmain. - Select Require merge queue.
- Under Require status checks to pass, add the checks that must pass.
- Save the rule.
Using a ruleset
- Open Settings, then Rules, then Rulesets.
- Choose New ruleset, then New branch ruleset.
- Name it, for example
main-merge-queue, and set Enforcement status to Active. - Under Target branches, add
main. - In the rules list, select Require merge queue and review the options below.
- Select Create.
New rulesets can be created as Evaluate or Disabled first. Active is what actually changes merge behavior.
Settings you will see
The form offers these options. The defaults are a reasonable starting point.
- Merge method: merge commit, squash, or rebase. This is how the queue lands pull requests.
- Build concurrency: how many merge groups the queue builds and tests at once.
- Group size: the minimum and maximum number of pull requests in one group, plus how long to wait for the minimum.
- Status check timeout: how long the queue waits for required checks before treating the group as failed.
- Grouping strategy: whether a group can merge only when all its entries pass, or whether it merges as long as its own checks pass.
A later chapter explains how to pick values. For a first rollout, keep the defaults and a small group size.
What changes for contributors
Once the rule is active, the Merge button on a pull request becomes Merge when ready. Pressing it adds the pull request to the queue instead of merging it. The queue does the merge only after the checks pass on the merge group.
The rule Require branches to be up to date before merging has no purpose once the queue is on. The queue already tests each pull request against the latest base plus the entries ahead of it, so contributors no longer need to rebase repeatedly.
Verify it works
Open a small pull request, approve it, and wait for its checks. Confirm the button reads Merge when ready. Add it to the queue and watch the Merge queue page, which you can reach from the repository's Pull requests tab or the branch's rule settings. A temporary branch with the prefix gh-readonly-queue/main/ should appear while checks run.
Exercise
A repository owner on a personal account cannot find the "Require merge queue" option in a ruleset. What is the most likely cause, and what would you check next for an organization repository that still lacks it?
Show answer
Merge queues are not available for repositories owned by personal accounts, so the repository would need to move to an organization. For an organization repository, check the plan, since private repositories need GitHub Enterprise Cloud, and confirm you have admin permission on the repository.