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.Open organization settings
Click the organization menu at the top of the sidebar and choose Settings
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
| Rule | Description |
|---|---|
| Require at least one review | Ensures that at least one team member has reviewed the change request before it can be merged. |
| Require all reviews approved | All completed (not requested) reviews must be approvals. If any reviewer has requested changes or rejected the change request, the merge will be blocked. |
| Require review by specified actors | Requires approval from all specified users. You can select specific team members who must review and approve the change request before it can be merged. |
| Require review by one of specified actors | Requires approval from at least one of the specified users. This is useful when you have multiple qualified reviewers but only need one approval from the group. |
| Require Docs Agent review | Requires a review from the GitBook AI agent. This ensures automated quality checks are performed on content changes before merging. (Coming soon) |
Change request requirements
| Rule | Description |
|---|---|
| Require up to date change request | The change request must be current with the primary content branch. If the primary content has been updated since the change request was created, you’ll need to rebase or update it before merging. |
| Require subject | The change request must have a descriptive subject/title. Empty subjects will block the merge. |
| Require description | The change request must include a description explaining what changes were made and why. |
Advanced options
| Rule | Description |
|---|---|
| Allow specified actors to bypass requirements | You can designate specific users who are allowed to bypass all other merge rule requirements. This is useful for administrators or emergency situations where rules need to be overridden. |
| Custom expression | You can create advanced merge rules using custom JavaScript expressions. This allows you to define complex logic based on the evaluation context, with access to properties of the change request, reviews, and the user attempting to merge. |
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