Auto-merge pull requests
Automatically merge pull requests when all merge requirements are met in Harness Code.
Auto-merge lets you queue a pull request to merge automatically once all merge requirements are satisfied. This is useful when a PR is ready for integration but is waiting on status checks, required approvals, or other branch rules to pass.
When auto-merge is enabled on a PR, Harness Code monitors its requirements continuously. As soon as every required check passes and all approvals are in place, the PR merges using the strategy you selected, with no manual action needed.
Prerequisites
Auto-merge enabled on the repository: A repository administrator must turn on the Allow auto-merge setting in repository settings before contributors can use auto-merge on individual PRs.
Open, non-draft pull request: Auto-merge is only available on PRs that are open and not in draft state.
Pending merge requirements: The Enable auto-merge button appears only when the PR has unmet requirements (status checks running, approvals pending, or branch rule violations) that currently block a direct merge. If the PR is already mergeable, you can merge it directly.
Enable auto-merge for a repository
Before contributors can use auto-merge on individual PRs, a repository administrator must enable it at the repository level.
In Harness Code, go to the repository where you want to enable auto-merge.
Go to Settings, and then select the General tab.
Under Features, select the Allow auto-merge checkbox.
The setting takes effect immediately. Contributors can now enable auto-merge on individual PRs in this repository.
Enable auto-merge on a pull request
Once auto-merge is enabled at the repository level, contributors can turn it on for individual PRs that have pending merge requirements.
In Harness Code, go to Pull Requests, and select the PR.
In the merge panel at the bottom of the Conversation tab, select a merge strategy from the Enable auto-merge dropdown:
Squash and merge: Combines all commits into a single commit on the base branch.
Merge pull request: Adds all commits to the base branch via a merge commit.
Rebase and merge: Rebases all commits onto the base branch.
Fast-forward merge: Moves the base branch pointer forward without creating a merge commit.
Available strategies depend on the repository's branch rules and the branch history.
For Squash and merge or Merge pull request, you can optionally customize the commit message and description.
Select Confirm auto-merge.
The merge panel updates to show that auto-merge is active and displays the selected merge strategy. The PR merges automatically when all requirements are met.
Disable auto-merge on a pull request
If you change your mind or need to adjust the merge strategy, you can disable auto-merge at any time before the PR is merged.
Go to the PR's Conversation tab.
Select Disable auto-merge.
The PR returns to its normal state and will not merge automatically.
Bypass rules with auto-merge active
If you have bypass permissions and auto-merge is active on a PR, you can choose to bypass branch rules and merge immediately instead of waiting for all requirements.
Select the Bypass and merge checkbox in the merge panel. This overrides the auto-merge queue and lets you merge the PR directly, following the standard merge flow.
Auto-merge failure
Auto-merge can be automatically disabled if the selected merge strategy is no longer supported by the repository's branch rules. For example, if an administrator removes Squash and merge from the allowed strategies after you enabled auto-merge with that method, auto-merge is disabled and a timeline entry appears on the PR:
disabled auto-merge — squash is no longer a supported merge method
To resolve this, enable auto-merge again with a strategy that is currently allowed.
Known limitation: rule, user group, and role changes
Auto-merge is event driven. The auto-merge subsystem re-evaluates a PR only when an event occurs on that PR, such as a status check reporting a result, an approval being submitted, or a new commit being pushed.
The following changes do not emit a PR event, so they do not re-evaluate pull requests that already have auto-merge active:
Rule edits: Any change to an existing rule, including adding or removing a required status check.
New rules: A rule created after auto-merge was enabled on the PR.
User group membership changes: Users added to or removed from a user group.
Role assignment changes: Roles granted to or revoked from a user or user group.
Rule level does not matter. Rules at the account, organization, project, and repository levels are all treated the same way.
If one of these changes is the only thing that makes a PR mergeable, the PR does not merge automatically. For example, an account-level rule requires three approvals. A PR collects two approvals, so auto-merge stays queued. An administrator then edits the rule to require two approvals. The PR now satisfies the requirement, but auto-merge does not merge it.
The PR displays the new, updated merge requirements, so the PR looks ready to merge even though auto-merge has not re-evaluated it. Use the merge panel state as a view of the current requirements, not as confirmation that auto-merge has processed them.
To merge a PR in this state, do any of the following:
Push a commit or submit an approval: Each of these emits an event that the auto-merge subsystem picks up, which triggers a new merge attempt.
Re-enable auto-merge: Disable auto-merge, and then enable auto-merge again. Enabling auto-merge attempts a direct merge first, so the PR merges immediately if it now satisfies every requirement.
Merge the PR yourself: Complete the manual merge flow with any strategy the branch rules allow.
This behavior is intentional. Harness Code supports rules at four levels, and a change at a higher level propagates to every level below it, so a single account-level rule edit would require inspecting every open pull request in every repository across the account. User groups and role assignments are also stored outside Harness Code. Reprocessing every auto-merge pull request on every such change is too expensive to justify, and a change to this behavior is not on the roadmap.
Troubleshooting
Next steps
You've learned how to configure and use auto-merge for pull requests in Harness Code. Auto-merge is especially useful in CI-heavy workflows where PRs frequently wait on pipeline checks before they can be integrated.
Merge PRs: Learn about merge strategies and requirements.
Branch rules: Configure required checks, approvals, and allowed merge strategies.
Review PRs: Understand the review and approval process.
Last updated
Was this helpful?