# Branch Protection Rules

Define branch protection rules to prevent direct changes and commits to specific branches. Only merges are allowed into protected branches. Together with the power of pre-merge [hooks](<https://docs.lakefs.io/guides/hooks/index.md>), you can run validations on your data before it reaches your important branches and is exposed to consumers.

You can create rules for a specific branch or any branch that matches a name pattern you specify with [glob](<https://en.wikipedia.org/wiki/Glob_(programming)>) syntax (supporting `?` and `*` wildcards).

## How it works

When at least one protection rule applies to a branch, the branch is protected. The following operations will fail on protected branches:

1. Object write operations: **upload** and **delete** objects.
2. Branch operations: **commit** and **reset uncommitted changes**.

To operate on a protected branch, merge commits from other branches into it. Use pre-merge [hooks](<https://docs.lakefs.io/guides/hooks/index.md>) to validate the changes before they are merged.

> [!NOTE]
>
> Reverting a previous commit using `lakectl branch revert` is **allowed** on a protected branch.

## Managing branch protection rules

This section explains how to use the lakeFS UI to manage rules. You can also use the [command line](<https://docs.lakefs.io/reference/cli/enterprise/index.md#lakectl-branch-protect>) and [API](<https://docs.lakefs.io/reference/api/enterprise/index.md>).

### Reaching the branch protection rules page

1. On lakeFS, navigate to the main page of the repository.
2. Click on the *Settings* tab.
3. In the left menu, click *Branches*.

### Adding a rule

To add a new rule, click the *Add* button. In the dialog, enter the branch name pattern and then click *Create*.

![Adding a branch protection rule](<https://docs.lakefs.io/assets/img/add_branch_protection_rule.png>)

### Deleting a rule

To delete a rule, click the *Delete* button next to it.

![Deleting a branch protection rule](<https://docs.lakefs.io/assets/img/delete_branch_protection_rule.png>)
