Documentation

Support

Unity Version Control

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
QUAK-*
need an approved review before they merge to the
main
branch:
[{ "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
examplerepo
repository. The merge rule ensures that only merges from source branches named
fixes-*
can merge to the destination branch
/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
game*
. This rule ensures that any branches that match the name
task*
can only receive merges from a parent branch:
[{ "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
game*
. This rule ensures that any branches that match the name
iteration*
can only receive merges from their child branches.