Types of merge rules
Explore the types of merge rules.
Read time 1 minuteLast updated 21 days ago
Learn what merge rules are available and refer to examples on how you can apply them. Find more information on how to set up merge rules.
Only allow reviewed merges
To only allow users to merge branches if they have an approved code review, use the following rule:only_allow_merges_if_reviewed
only_allow_merges_if_reviewed
example
The following example applies to all repositories and ensures that all branches that follow the naming pattern only_allow_merges_if_reviewedQUAK-*main[{ "enabled": true, "repositories": "*", "rule": "only_allow_merges_if_reviewed", "to": { "branchNames": ["main"] }, "from": { "branchNames": ["QUAK-*"], }}]
Restrict merges to a branch
To ensure that merges to a specific branch can only come from a defined set of branches, use the following rule:restrict_merges_to_branch
restrict_merges_to_branch
example
The following example applies to only the restrict_merges_to_branchexamplerepofixes-*/fix3.0[{ "enabled": true, "repositories": "examplerepo", "rule": "restrict_merges_to_branch", "to": { "branchNames": ["/fix3.0"], }, "from": { "branchNames": ["fixes-*"], }}]
Only allow merges from a parent branch
To only allow merges to a given branch if the merge is from its parent branch, use the following rule:only_allow_merges_from_parent
only_allow_merges_from_parent
example
The following example applies to repositories that match the name only_allow_merges_from_parentgame*task*[{ "enabled": true, "repositories": "game*", "rule": "only_allow_merges_from_parent", "to": { "branchNames": ["task*"], }}]
Only allow merges from a child branch
To only allow merges to a given branch if the merge is from its child branches, use the following rule:only_allow_merges_from_children
only_allow_merges_from_children
example
The following example applies to repositories that match the name only_allow_merges_from_childrengame*iteration*