GitDBDocs
gitdb.co platform

Branch protection

Protect important branches from direct pushes, force pushes, and deletion, and require approved pull requests.

Branch protection rules stop direct pushes, force pushes, and deletions on the branches that matter, and can require approved pull requests. Rules are per repository, in Settings → Branches under Branch protection rules ("Protect branches by restricting who can push, force-push, or delete").

Add a rule

  1. Open the repository's Settings → Branches and click ADD RULE →.

  2. Enter a Branch name pattern (see Patterns).

  3. Choose the options you want. All of them start unchecked:

    OptionEffect
    Require pull request before mergingDirect pushes to an existing matching branch are refused. Changes have to arrive by merging a pull request.
    Required approvals (shown when the option above is checked, 0 to 10)A pull request into the branch can't be merged until it has this many approvals. See Pull requests.
    Allow force pushesUnchecked: pushes that rewrite the branch's history are refused.
    Allow branch deletionUnchecked: deleting the branch is refused.
    Enforce rules on administratorsUnchecked: organization owners and admins bypass the rule. Checked: the rule applies to everyone.
  4. Click CREATE RULE →.

Each rule appears in the list with its pattern and chips summarizing it: PR required (N approvals), No force push, No delete, and Enforced on admins. Click Delete to remove a rule.

Patterns

PatternMatches
mainExactly the branch main
release/*Every branch whose name starts with release/, for example release/1.0 and release/2025/q1
feature/*Every branch whose name starts with feature/

A pattern is either an exact branch name, or a prefix followed by *. Enter one pattern per rule. If more than one rule could match the same branch, only one of them is applied, so avoid overlapping patterns.

What happens on push

When a push breaks a rule, Git shows the refusal and nothing is changed on gitdb.co:

SituationMessage
Pushing new commits to a branch that requires pull requestsbranch 'main' is protected — changes must be made through a pull request
Force-pushing when force pushes aren't allowedbranch 'main' is protected — force push not allowed
Deleting the branch when deletion isn't allowedbranch 'main' is protected — deletion not allowed

A few details:

  • Rules apply to branches only, not tags.
  • Pushing a new branch whose name matches a pattern is allowed. The rule applies from then on.
  • Merging a pull request is the intended way into a branch that requires pull requests, so it isn't blocked by that option. It is still subject to Required approvals.
  • Merges into a protected branch made outside a pull request (for example by an AI agent) are refused the same way as a direct push when the rule requires pull requests or approvals.
  • The same rules apply whether you push over SSH or HTTPS.
  • Unless Enforce rules on administrators is checked, organization owners and admins can still push, force-push, delete, and merge without approvals.

On this page