Skip to Content
GitDBDocs
gitdb.net 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 (the default branch already has a rule created for it automatically, see Default branch protection):

    OptionEffect
    Require pull request before mergingDirect pushes to an existing matching branch, and commits made directly to it on gitdb.net, 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.

Default branch protection

When a repository's default branch is set for the first time, or changes, gitdb.net automatically creates a protection rule for it: Require pull request before merging is on, force pushes and deletion are not allowed, and organization owners and admins can bypass it (Enforce rules on administrators is off). If a rule for that exact branch name already exists, it is left exactly as it is and no new rule is created.

The automatic rule appears in the list like any other rule. To change it, add a rule with the same branch name pattern and the options you want; it replaces the automatic rule's options. Click Delete to remove it.

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 matches the same branch, exactly one of them applies:

  • A rule for the exact branch name always wins over * patterns.
  • Among * patterns, the one with the longest prefix wins. For example, on release/2025/q1, release/2025/* applies rather than release/*.
  • If two * patterns have the same prefix, the older rule wins.

What happens on push

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

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.
  • Commits made directly on gitdb.net are refused the same way when the rule requires pull requests or approvals. That covers an AI agent committing with the gitdb_commit MCP tool and commits from the VS Code extension. The refusal reads branch 'main' is protected — changes must be made through a pull request. Commit to another branch and open a pull request instead.
  • 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, commit directly, force-push, delete, and merge without approvals.

On this page