gt-branch-protect(1)

gt-branch-protect1

Protect branches

Usage

gt branch protect <branch> ... [flags]

Overview

Add a protection rule for each existing branch, or with --pattern for every branch matching a glob. By default nobody can push directly and pull requests need one approving review.

When a branch or pattern has a rule already, change only the settings the flags name and keep the others; --allow-push replaces those who may push directly. An empty --allow-push= lets nobody push directly again, and an empty --status-check= stops requiring status checks.

Options

--allow-push=[]
Users, or teams as ORG/TEAM, that may push directly

--block-on-rejected-reviews[=false]
Block merging while changes are requested

--dismiss-stale-approvals[=false]
Dismiss approvals when new commits are pushed

-h, --help[=false]
help for protect

--pattern=""
Protect the branches matching this glob, such as release/*

--required-approvals=1
Approving reviews that pull requests need

--status-check=[]
Status checks that must pass (repeatable)

Options inherited from parent commands

--cwd=""
Working directory for repository discovery

--debug[=false]
Log the method, URL, status, and duration of each HTTP request to stderr

--host=""
Gitea instance URL, including any base path

--interactive[=false]
Allow prompts with machine output

--no-input[=false]
Disable prompts and implicit editor/browser interactions

--remote=""
Git remote used for repository discovery

-R, --repo=""
Select a repository as OWNER/REPO or URL

--sudo=""
Perform API requests as this user (requires an administrator account)

--user=""
Account name on the selected instance

Examples

# Require two approvals and passing CI on main
$ gt branch protect main --required-approvals 2 --status-check ci/build
# Let the release team push to every release branch
$ gt branch protect --pattern 'release/*' --allow-push acme/release
# Stop requiring status checks on main
$ gt branch protect main --status-check=

From gitea-cli 1.0.0-1 in Arch Linux 2026-11-07. Parsed by carta from the page's man source.