Skip to main content
Merge rules are available on Pro and Enterprise plans.
Merge rules allow you to define requirements that must be met before change requests can be merged, such as needing a review from a specific user, or requiring a subject or description for the change request. These rules help maintain content quality and ensure proper review processes across your documentation workflow. When you have merge rules configured, they’ll automatically evaluate change requests before they can be merged. If a rule isn’t satisfied, the merge will be blocked until the requirements are met. This provides an automated way to enforce your team’s collaboration and review standards.

Using merge rules

You can configure merge rules at different levels to match your team’s workflow.

Organization-level configuration

Organizations can set default merge rules that all spaces inherit. This provides consistency across multiple spaces while still allowing individual spaces to customize their rules as needed.
1

Open organization settings

Click the organization menu at the top of the sidebar and choose Settings
2

Navigate to merge rules

In the Settings screen, select Merge rules under the Organization section
3

Configure rules

Choose between unrestricted merging or select from the list of presets to apply across your entire organization

Space-level configuration

Whether or not you have enabled organization-wide merge rules, each space can have its own merge requirements tailored to its content and team structure. This gives you the flexibility to have stricter rules for important documentation and more relaxed rules for draft content. When setting up merge rules for a space, you can choose to:
  • Inherit merge rules from your organization
  • Define custom rules specific to that space
  • Disable merge rules entirely
If you inherit organization rules, any changes to the organization’s merge rules will automatically apply to the space.
To configure merge rules for a space, open the Actions menu in the top left of the editor, and then select Merge rules. Here you can specify whether to inherit the merge rules from your organization or configure new ones specific to that space.

Rule evaluation

How rules work

When someone wants to merge a change request, GitBook will evaluate all the configured rules in order:
  • All rules in a configuration must pass for a merge to be allowed
  • Rules are evaluated in the order they appear in your configuration
  • If any rule fails, the merge is blocked with an appropriate error message
  • Rules with bypass capabilities can override previous failures

Bypass rules

Some rules have bypass capabilities (like Allow specified actors to bypass requirements). These special rules can override other rule failures. If a bypass rule evaluates to true, the merge will be allowed even if other rules have failed.

Available rule types

Review requirements

Change request requirements

Advanced options

Custom expressions

When you create a custom expression, it will be evaluated each time someone tries to merge a change request. If the expression returns true, the merge is allowed. If it returns false, the merge is blocked.
Custom expressions support standard JavaScript syntax (ES2022) and have a maximum length of 1024 characters.
Available context variables:
  • changeRequest.subject - The subject/title of the change request
  • changeRequest.description - The description of the change request
  • changeRequest.outdated - Whether the change request is outdated (boolean)
  • changeRequest.createdBy.id - ID of the user who created the change request
  • reviews - Array of review objects, each containing:
    • reviews[].status - Review status ("approved" or "changes_requested")
    • reviews[].reviewer.id - ID of the reviewer
  • actor.id - ID of the user attempting to merge
Common expression examples:

Best practices

When setting up merge rules, consider these recommendations:
  • Start simple: Begin with basic rules like requiring at least one review
  • Scale gradually: Add more specific requirements as your team grows and workflows mature
  • Use bypass carefully: Only grant bypass permissions to trusted administrators
  • Review regularly: Adjust rules based on your team’s actual workflow patterns
  • Test first: When possible, test rule changes in a test space before applying to production spaces