Merge rules are available on Pro and Enterprise plans.
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.
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 returnstrue, 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.
changeRequest.subject- The subject/title of the change requestchangeRequest.description- The description of the change requestchangeRequest.outdated- Whether the change request is outdated (boolean)changeRequest.createdBy.id- ID of the user who created the change requestreviews- 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
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