Sub topic 9
Day to day: queueing and dequeueing pull requests
This chapter assumes you have already enabled a merge queue on main. It also assumes your workflows run on the merge_group event and your required checks are set up. Here you will use the queue as a developer.
What changes in the pull request
With a merge queue active, the pull request merge button changes. You can no longer merge directly into the protected branch.
- If required checks and reviews are still pending, the button reads Merge when ready.
- If everything is satisfied, the button reads Add to merge queue.
- The merge method is no longer your choice. The queue's configured method (merge, squash, or rebase) applies to every entry.
A pull request is eligible to be queued when it meets the normal branch requirements: required approvals, passing required checks on the pull request branch, and resolved conversations if you require them. The queue adds a second test on top of that. It does not replace the first one.
The lifecycle of an entry
After you queue a pull request, the page shows its position. When it reaches the front, GitHub creates a temporary branch named like gh-readonly-queue/main/pr-123-<sha>. This branch contains the latest main, the changes queued ahead of you, and your changes. Your merge_group workflows run against that branch. If they pass, the queue merges your pull request in order.
Queueing from the command line
The GitHub CLI handles the queue for you. When the target branch requires a queue, gh pr merge adds the pull request to it instead of merging directly.
gh pr merge 123 --squash
gh pr view 123 --json mergeStateStatus,autoMergeRequestPass the merge-method flag your queue uses. If the flag conflicts with the queue's configured method, the queue's method still wins. Check the pull request page to confirm the entry was accepted.
Removing a pull request
Sometimes you need to pull an entry out. Common reasons are that you found a bug after approving, or that you want to add commits.
- Open the pull request.
- In the merge box, choose Remove from merge queue.
- Alternatively, open the repository's merge queue view for the branch and remove the entry there.
Removing an entry returns the pull request to the open state. Entries queued behind it are rebuilt without your changes, so their checks restart. Removing an entry near the front of a long queue therefore costs CI time for everyone behind it.
Entries can also leave the queue without your action. Failed required checks on the merge group branch remove it, and so does a check timeout. The pull request timeline records the reason, so read it before you re-queue.
Do not push new commits to a pull request that is queued and assume the queue tests them. The queue tests a specific merge group commit. Remove the entry, push, wait for the pull request checks, then queue it again.
Bypassing the queue
Repository administrators and users on a bypass list can sometimes merge outside the queue. Bypass skips the protection that prevents stale merges. Reserve it for urgent fixes, and expect queued entries to be rebuilt afterward.
Quick checks for a healthy habit
| Situation | What to do |
|---|---|
| Checks pass on the pull request, queue not yet used | Click **Add to merge queue** |
| Need to add commits | Remove from the queue, push, re-queue |
| Entry removed unexpectedly | Read the timeline, then fix and re-queue |
| Urgent hotfix | Queue normally unless you have an approved bypass |
Exercise
You queued pull request 42, then realize it needs another commit. Two pull requests are queued behind it. What should you do, and what is the side effect on the other two?
Show answer
Remove pull request 42 from the queue, push the commit, wait for its pull request checks to pass, then add it to the queue again. The two entries behind it are rebuilt without 42's changes, so their merge group checks restart and they cost extra CI time. When 42 is queued again it goes to the back of the line.