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. Go to Enable auto-merge for a repository to turn on this setting.
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.
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?