Skip to main content
wit provides comprehensive branch protection rules to safeguard important branches like main, release/*, and others from accidental or unauthorized changes.

Overview

Branch protection allows you to:
  • Block direct pushes (require pull requests)
  • Prevent force pushes
  • Block branch deletion
  • Require code reviews
  • Enforce status checks
  • Restrict who can push

Quick Start

Commands

List Rules

Add a Rule

Examples:

Update a Rule

Examples:

Remove a Rule

Show Rule Details

Check Operations

Verify if an operation would be allowed:

Protection Status

See a summary of protection for a branch:

Options

Push Restrictions

Review Requirements

Status Checks

Metadata

Presets

wit includes built-in presets for common protection scenarios:

Basic

  • Blocks force push
  • Blocks deletion
  • Allows direct push

Standard

  • Requires pull request
  • Requires 1 approval
  • Dismisses stale reviews
  • Blocks force push
  • Blocks deletion

Strict

  • Requires pull request
  • Requires 2 approvals
  • Dismisses stale reviews
  • Requires code owner review
  • Requires status checks
  • Requires branch up-to-date
  • Blocks force push
  • Blocks deletion

Pattern Matching

Protection rules support glob-style patterns: Examples:

Storage

Branch protection rules are stored in .wit/branch-protection.json:

Enforcement

Push Operations

When you attempt to push to a protected branch:

Force Push

Branch Deletion

Programmatic Usage

Branch protection can be managed programmatically:

Best Practices

Main Branch

Release Branches

Feature Branches

Generally, feature branches don’t need protection, but you might want to protect long-running ones:
  • wit merge - Merge branches with conflict resolution
  • wit pr - Pull request management
  • wit hooks - Pre-commit and pre-push hooks